有人可以向我解释Intents在Android OS中的基本功能吗?

有人可以向我解释Intents在Android OS中的基本功能吗?,第1张

概述我是Android *** 作系统应用程序编程的新手.就 *** 作系统的一般体系结构而言,我了解到进程是作为Linux进程实现的,并且每个进程都是沙盒化的.但是,我对使用的IPC和syscall(如果有的话)完全感到困惑.我知道IBinder是这种形式.包裹在进程之间来回发送,捆绑商品是包裹的数组形式(?).但这对

我是Android *** 作系统应用程序编程的新手.就 *** 作系统的一般体系结构而言,我了解到进程是作为linux进程实现的,并且每个进程都是沙盒化的.

但是,我对使用的IPC和syscall(如果有的话)完全感到困惑.我知道IBinder是这种形式.包裹在进程之间来回发送,捆绑商品是包裹的数组形式(?).但这对我还是不熟悉.与意图相同.总而言之,我不了解实施了哪种IPC以及如何实现.

有人可以简要地向我解释AndroID OS中的用户级应用程序用于相互通信以及与OS进行通信的具体方法吗?我已经完成了内核编程,并在linux中使用了各种IPC(Ubuntu和Debian),所以如果所有这些都相对于我所熟悉的有所解释的话,它将提供极大的帮助.

提前致谢!

解决方法:

AndroID是Service Oriented Architecture,这意味着设备上的所有应用程序都由要求使用high level messages called Intents的其他组件执行工作的组件组成.在幕后,跨越应用程序的意图是使用依赖于special Android flavor of shared memory的Binder发送的,应用程序开发人员非常高兴地不知道该实现.唯一的要求是,当一个组件要传递一个对象及其“意图”以请求另一个位于不同进程中的组件进行工作时,该对象必须为parcelable(认为可序列化).此外,为了使应用程序可以使用其他应用程序的Intent,必须在manifest file中使用Intent Filter发布这些Intent.

想要触发网页显示的应用程序将具有如下代码:

public class OpenInternet extends Activity {    /** Called when the activity is first created. */    @OverrIDe    public voID onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentVIEw(R.layout.main);        ((button) findVIEwByID(R.ID.OpenInternetbutton))                .setonClickListener(new VIEw.OnClickListener() {                    @OverrIDe                    public voID onClick(VIEw v) {                        Intent i = new Intent(Intent.ACTION_VIEW, Uri                                .parse("http://www.Google.com"));                        startActivity(i);                    }                });    }}

能够通过显示网页来为该Intent服务的另一个应用程序将在其清单中定义以下intent过滤器,以便它可以捕获另一个应用程序发送的Intent:

        <!-- For these schemes were not particular MIME type has been             supplIEd, we are a good candIDate. -->        <intent-filter>            <action androID:name="androID.intent.action.VIEW" />            <category androID:name="androID.intent.category.DEFAulT" />            <category androID:name="androID.intent.category.broWSABLE" />            <data androID:scheme="http" />            <data androID:scheme="https" />            <data androID:scheme="about" />            <data androID:scheme="JavaScript" />        </intent-filter>        <!--  For these schemes where any of these particular MIME types              have been supplIEd, we are a good candIDate. -->        <intent-filter>            <action androID:name="androID.intent.action.VIEW" />            <category androID:name="androID.intent.category.broWSABLE" />            <category androID:name="androID.intent.category.DEFAulT" />            <data androID:scheme="http" />            <data androID:scheme="https" />            <data androID:scheme="inline" />            <data androID:mimeType="text/HTML"/>            <data androID:mimeType="text/plain"/>            <data androID:mimeType="application/xhtml+xml"/>            <data androID:mimeType="application/vnd.wap.xhtml+xml"/>        </intent-filter>

除了使用Intent,您还可以使用AIDL创建具有代理对象的对象,该代理对象使您可以跨流程边界执行remote procedure calls.

您可能不必担心libc如何执行系统调用,因为您正在VM内运行,并且已从其中删除了几个级别.就“正常” IPC而言,您有套接字,但您认为don’t have System V Shared Memory有问题并已删除.

总结

以上是内存溢出为你收集整理的有人可以向我解释Intents在Android OS中的基本功能吗?全部内容,希望文章能够帮你解决有人可以向我解释Intents在Android OS中的基本功能吗?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1092498.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存