0

Can any one tell me how to pass data through bundle or any thing else between two installed applications in android?

I have googled around but could not get any proper guide

I give a try to Content Provider As suggested on some similar such query Data sharing between two applications but i am very much new to content provider, I try to get some thinng from official documents but could not get succeeded

Thanks Any way

Community
  • 1
  • 1
Aamirkhan
  • 5,746
  • 10
  • 47
  • 74

4 Answers4

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);
Parag Chauhan
  • 35,760
  • 13
  • 86
  • 95
2

For sharing data android offers the Intent class.

Ahmad Dwaik 'Warlock'
  • 5,953
  • 5
  • 34
  • 56
2

You may simply use a BroadcastReceiver. If you follow the Android tag, you'll notice how usually it's recommended using local BroadcastReceivers and local sendBroadcasts(). In your case you need global BroadcastReceivers so you can comunnicate at inter-app level. I'd recommend using custom Actions to broadcast, as Android system's might cause missfunctions if you don't handle them well.

Broadcasts use Intents to communicate.

More info on BroadcastReceiver here, and you'll find a very good example here.

nKn
  • 13,691
  • 9
  • 45
  • 62
1

if you mean two separated applications You can write data to file from one application and read the file from other application

Omnya.Alaa
  • 21
  • 1
  • 8
  • Not the best solution. Where you locate this file? – anber Feb 13 '14 at 13:44
  • in a path in Application project – Omnya.Alaa Feb 13 '14 at 13:45
  • using sharedPrefarance we can achive with same key – Parag Chauhan Feb 13 '14 at 13:46
  • MODE_WORLD_READABLE: Creating world-readable files is very dangerous, and likely to cause security holes in applications. It is strongly discouraged; instead, applications should use more formal mechanism for interactions such as ContentProvider, BroadcastReceiver, and Service. There are no guarantees that this access mode will remain on a file, such as when it goes through a backup and restore. File creation mode: allow all other applications to have read access to the created file. http://developer.android.com/reference/android/content/Context.html#MODE_WORLD_READABLE – anber Feb 13 '14 at 13:54