2014-02-13 53 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我們可以使用相同的鍵達到 –

相關問題