Android跨应用数据传递

标签 android plugins android-contentprovider cross-application

概览

我正在创建一个 Android 应用程序,它将扫描设备的各个方面(联系人、apn、电子邮件等)

我想让第 3 方应用程序在安装/运行/启动等时向我的应用程序注册 - 使其数据可供我的应用程序使用。

问题

如何以标准方式访问此信息?如果我正在创建一个典型的插件式桌面应用程序,我会使用某种形式的界面,但 Android 没有这种能力。我查看了 ContentProviders,但第 3 方应用程序需要开发一个完整的 SQLite 数据库以允许我的应用程序访问其数据。这似乎有点矫枉过正。

有什么办法可以实现吗?

最佳答案

I would use some form of Interface if I was creating a typical plugin-style desktop app, but Android doesn't have this ability.

Sure it does .

I have looked into ContentProviders but the 3rd party app would need to develop a whole SQLite database to allow my app to access its data.

不,他们没有。 ContentProvider 是一个门面。您可以随心所欲地实现一个。

What I would like to make possible is for 3rd party application to register with my app on install/run/boot etc - making its data available to my application.

“安装”是不可能的。在首次运行和/或启动时将是可能的。

How can I access this information in a standard way?

如果您的应用程序将提取数据,除了 ContentProvider 或 AIDL 接口(interface)之外,您可以通过 startService() 向第三方应用程序发送命令,并且在 Intent 中包含一个额外的内容,它为第三方应用程序提供了一个用于发送其响应的 channel (例如,一个 Messenger,一个 PendingIntent,一个 ResultReceiver)。

相反,如果第三方应用程序将向您推送数据,我将实现一个 BroadcastReceiver,在您的 list 中注册,并让第三方应用程序根据需要发送广播。

关于Android跨应用数据传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7858995/

相关文章:

java - Android Studio上的错误(方法未从其父类(super class)重写方法)

具有主页和后退按钮的 Android 工具栏

android - CodeGlance 插件不会改变 Android Studio 中编辑器的外观

java - 如何获取另一个java项目的类路径?

Android:使用 ContentResolver 时的 SQLite 事务

android - 没有 ContentProvider 的 SyncAdapter

android - 创建的图像在 android 图库中无法识别

android - Visual Studio 2015 中的 "No devices available"

cocoa - 跨插件共享单个 cocoa 框架副本

android - 我需要带有游标加载器的内容提供程序吗?