After lot of googeling, I could not find any way to pass a object from one application to other application.Though I know that we can pass object from one activty to other activity using Parcel but how to do this between applications? My object is this
public class MyObject
{
private String name;
public String getName()
{
return this.name;
}
public void setName(String name)
{
this.name=name;
}
}
Then how to do this like we do for passing object between activities
intent.putExtra("key",new MyOject());
I'm assuming you're in charge of both applications.
Which of these situations is true?
If the first situation is true, the normal way would be to create an Android Content Provider (as suggested previously) or a Service, which exposes an API using the AIDL language. Both applications would then depend upon the Content Provider or the Service.
See here for information about AIDL and services: http://developer.android.com/reference/android/app/Service.html http://developer.android.com/guide/components/aidl.html
If however the applications are peers, then the existing answers about Intents are good. Either one application can trigger another simply using startActivity, or perhaps you want to provide a way for a user to choose to share the object from one to the other. Look at this:
http://developer.android.com/training/sharing/send.html
One suggestion could be using ContentProviders
from reference:
Content providers are one of the primary building blocks of Android applications, providing content to applications. They encapsulate data and provide it to applications through the single ContentResolver interface.
Another suggestion could be using SharedPreferences, with getSharedPreferences with a correct mode. But as you can see in the reference some modes are deprecated since API Level 17.
Hope this helps, if not comment below
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With