2014-02-13 56 views
0

任何人都可以告诉我如何在Android中使用two installed application之间的pass data through bundle or any thing如何将数据从一个应用程序传递到另一个Android

我用Google搜索周围,但不能得到任何适当的引导

我给一个尝试Content Provider至于一些类似这样的查询Data sharing between two applications建议,但我非常新的内容提供商,我试图从一些thinng官方文件,但没能成功

感谢任何方式

回答

2

您可以简单地使用BroadcastReceiver。如果您按照Android标签,您会注意到通常建议使用本地BroadcastReceiver和本地sendBroadcasts()。在你的情况下,你需要全球BroadcastReceiver s,所以你可以在应用程序间级别comunnicate。我建议使用自定义Actions进行广播,因为如果处理不当,Android系统可能会导致失误。

广播使用Intent s进行通信。

更多关于BroadcastReceiverhere的信息,你会发现一个很好的例子here

2

共享数据,Android提供了Intent类。

3
Intent intent = new Intent("android.intent.action.MAIN"); 
intent.setComponent(ComponentName.unflattenFromString("another app package name")); 
intent.addCategory("android.intent.category.LAUNCHER"); 
Bundle bundle = new Bundle(); 
bundle.putInt("key", 1); 
intent.putExtras(bundle); 
startActivity(intent); 
1

,如果你的意思是两个独立的应用程序 你可以写数据从一个应用程序文件和读取文件从其他应用程序

+0

不是最好的解决方案。你在哪里找到这个文件? – anber

+0

在应用程序项目中的路径 –

+0

使用sharedPrefarance我们可以使用相同的键达到 –

相关问题