Android 中如何共享应用程序组件?
自从我开始阅读有关 android 的文章以来,已经有一段时间了。 我已经制作了一些基本的应用程序,但我仍然错过了一些东西:共享应用程序组件实际上是如何完成的? Android 开发指南是这样说的:
Android 的一个核心功能是一个应用程序可以使用其他应用程序的元素(前提是这些应用程序允许)。例如,如果您的应用程序需要显示图像的滚动列表,并且另一个应用程序已开发了合适的滚动器并将其提供给其他应用程序,则您可以调用该滚动器来完成这项工作,而不是开发自己的滚动器。您的应用程序不包含其他应用程序的代码或链接。相反,它只是在需要时启动另一个应用程序的该部分。
我想我遇到过这样的问题,但我想我仍然很困惑。 获取此类“私人应用程序”信息的唯一方法是联系该应用程序的开发人员吗?
有关应用程序操作的数据的信息也是私有的吗? 如果它在 AndroidManifest.xml 文件中描述,它是否可用于其他应用程序,或者仅适用于 Android?
当我开始满足我对 Android 的兴趣时 - 吸引我的事情之一就是巨大的互操作性的印象......
:)
是我错了还是我还没有找到方法?
谢谢!
it's been some time now, since I started reading about android.
I've already made a few basic applications, but I still miss something: How is actually sharing application component being done?
This is what the Android Dev Guide says:
A central feature of Android is that one application can make use of elements of other applications (provided those applications permit it). For example, if your application needs to display a scrolling list of images and another application has developed a suitable scroller and made it available to others, you can call upon that scroller to do the work, rather than develop your own. Your application doesn't incorporate the code of the other application or link to it. Rather, it simply starts up that piece of the other application when the need arises.
I think I came across some question like this, but I think I'm still confused.
Is the only way of getting such a 'private application' information to contact the developers of that application?
Is information about the data that the application operates with private, too?
If it is described in the AndroidManifest.xml file is it available for the other applications, or it is available only to Android?
When I started satisfying my interest in Android - one of the things that grabbed me was the impression of immense interoperability...
:)
Have I been wrong or I still haven't found the way?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这完全取决于您认为“应用程序组件”是什么,以及您认为“共享”是什么。
,这是文档中相当糟糕的一部分。我是这样写的:
Android 的一个核心特性是一个应用程序可以使用其他应用程序的组件(例如,活动、服务)(只要这些应用程序允许)。例如,如果您的应用程序需要显示联系人列表,而另一个应用程序已经开发了一个活动来完成此任务并将其提供给其他人,那么您可以调用该活动来完成这项工作,而不是开发自己的活动。您的应用程序不包含其他应用程序的代码。相反,它只是在需要时启动其他应用程序的该部分。
开发人员要么打算让您与他们集成,要么不想。如果是的话,他们应该记录如何做到这一点(例如,与
startActivity()
一起使用的Intent
格式来触发他们的代码)。如果他们没有记录此类集成点,您当然可以要求开发人员添加一些。然而,随机向他们发射Intent
以期获得响应,即使它暂时有效,也比脚本小子策略好不了多少——这些开发人员没有义务确保您的代码在升级其代码时可以正常工作。应用程序。我不知道“有关应用程序操作的数据的信息”是什么意思。默认情况下,应用程序管理的数据是私有的。同样,应用程序开发人员可以提供数据集成点(例如,内容提供商、远程服务 API)——有些提供,有些则不提供。
与其他一些移动平台相比,Android 提供了更大的互操作性潜力。然而,利用这种潜力需要互操作者之间的同意。您不能仅仅因为您愿意而单方面决定侵入另一个应用程序的数据库或调用私人活动。
是否应该有更多的 Android 开发者提供更多的集成点?从抽象的角度来看,当然可以。然而,请记住,这会增加支持成本(例如,回答集成问题)并限制编码灵活性(例如,需要为进行集成的人员维护稳定的 API)。如果开发商不想承担这一切,就不能责怪他们。
That depends entirely on what you consider an "application component" to be, and what you consider "sharing" to be.
That is a fairly bad piece of the documentation. Here is how I would write it:
A central feature of Android is that one application can make use of components (e.g., activities, services) of other applications (provided those applications permit it). For example, if your application needs to display a list of contacts and another application has developed an activity that does just that and made it available to others, you can call upon that activity to do the work, rather than develop your own. Your application doesn't incorporate the code of the other application. Rather, it simply starts up that piece of the other application when the need arises.
Either developers are intending for you to integrate with them, or they are not. If they are, they should be documenting how to do that (e.g.,
Intent
formats to be used withstartActivity()
to trigger their code). If they do not document such integration points, you can certainly ask the developers to add some. However, randomly shootingIntents
at them in hopes of getting a response, even if it temporarily works, is little better than script kiddie tactics -- those developers are not obligated to ensure you code works when they upgrade their app.I do not know what "information about the data that the application operates with" means. Data managed by an application is private by default. Again, application developers can offer integration points for data (e.g., content provider, remote service API) -- some do, some do not.
Android offers greater interoperability potential than some other mobile platforms. However, using that potential requires consent among the interoper-ees. You cannot unilaterally decide to hack into another app's database, or invoke private activities, just because you feel like it.
Should more Android developers offer more integration points? In the abstract, sure. However, bear in mind that this adds support costs (e.g., answering integration questions) and limits coding flexibility (e.g., need to maintain a stable API for those doing the integrating). Developers cannot be blamed if they do not wish to incur all that.