Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send data from one application to other application in android?

I need to send some string data from my one application activity to my other application activity in android and not between the activities within the same application. How to do that? What intent filters my other application need to declare? Please try to elaborate with example.....

like image 702
SACHIN DHIVARE Avatar asked Jan 16 '13 10:01

SACHIN DHIVARE


People also ask

Which package helps to exchange data between two applications?

Although you can design your own system for doing data transfers in your app, you should consider using Android's sync adapter framework. This framework helps manage and automate data transfers, and coordinates synchronization operations across different apps.

What are the three ways of storing data in Android application?

Android App Development for Beginners These storage places are shared preferences, internal and external storage, SQLite storage, and storage via network connection. In this chapter we are going to look at the internal storage. Internal storage is the storage of the private data on the device memory.

Do apps share data?

While some of the reasons apps collect your data are legitimate — like tracking how you interact with them to make your experience better and to fix bugs — the company behind the app also can sell or pass this information to third parties that then target you with ads on their platforms.


2 Answers

As far as I could understand from your answer you're looking for intents:

On the manifest of App A - Activity Alpha you declare a intent filter with Category DEFAULT and Action = com.your_app_package_name.your_app_name.ActivtiyAlpha

The on App B, Activity Beta you put the code to launch A and 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

Then back on App A - Activity Alpha you put the code:

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
}
like image 94
Budius Avatar answered Oct 16 '22 13:10

Budius


If you're concerned with only a small amount of data, Android provides a SharedPreferences class to share preferences between applications. Most notably, you can add OnSharedPreferenceChangeListener to each application so they can be notified when the other changes the value.

Most importantly, you can't ensure that both applications are running

You can find more information on http://developer.android.com/guide/topics/data/data-storage.html

like image 2
user1954492 Avatar answered Oct 16 '22 11:10

user1954492