-4

How to pass an custom object between applications using intent in android?

curious_cat
  • 808
  • 2
  • 10
  • 14

3 Answers3

0

Try something like below. Put below code in your main activity from where you want to pass the data.

Intent i = new Intent("com.your_app_package_name.your_app_name.ActivtiyAlpha");
i.putExtra("KEY_DATA_EXTRA_FROM_ACTV_B", myString);
// add extras to any other data you want to send to b

and in other activity.

Bundle b = getIntent().getExtras;
if(b!=null){
    String myString = b.getString("KEY_DATA_EXTRA_FROM_ACTV_B");
    // and any other data that the other app sent
}
InnocentKiller
  • 5,207
  • 7
  • 34
  • 84
0

Implementing Parcelable might seems like a good fit, but it would cause issues if you ever modify your object structure. Both applications would need to be up-to-date, or the de-serialization would crash.

I would go for a JSON or XML serialization, and pass the String as an Intent extra.

nicopico
  • 3,571
  • 1
  • 26
  • 30
0

You can use Content Provider to share data between applications... This is the link

Looking Forward
  • 4,200
  • 8
  • 46
  • 66