Data Sharing Between Two Applications

Data sharing between two applications

ContentProviders are a good approach to share data between applications.

How to share data Between two Application

You can use content provider . here is detail and example

Sample Image

Data sharing between two application in android

Send data from Application 1 (for ex:Application 1 package name is "com.sharedpref1" ).

SharedPreferences prefs = getSharedPreferences("demopref",
Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putString("demostring", strShareValue);
editor.commit();

Receive the data in Application 2( to get data from Shared Preferences in Application 1).

    try {
con = createPackageContext("com.sharedpref1", 0);//first app package name is "com.sharedpref1"
SharedPreferences pref = con.getSharedPreferences(
"demopref", Context.MODE_PRIVATE);
String your_data = pref.getString("demostring", "No Value");
}
catch (NameNotFoundException e) {
Log.e("Not data shared", e.toString());
}

In both application manifest files add same shared user id & label,

 android:sharedUserId="any string" 
android:sharedUserLabel="@string/any_string"

both are same... and shared user label must from string.xml

like this example.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.xxxx"
android:versionCode="1"
android:versionName="1.0"
android:sharedUserId="any string"
android:sharedUserLabel="@string/any_string">

How to share data between two applications with SSO?

The SAML way is to use NameID as the "primary key" to map a user in the IDP to a user in the application.

e.g. Email could be sent as the NameID for application 1 and UPN could be sent as the NameID for application 2. These would be in the assertions.

Getting info. between applications is not part of an IDP (other than using assertions) so this would have to be done via API.

Sharing data between two applications

why not you are using xml as a mediator between two application. Use XML for the communication.

Passing data between two android apps using intent

Try this:

AppA's AndroidManifest.xml:

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.joy.AppA">
.
.
.
<activity
android:name="com.joy.AppA.views.activities.StartGameActivity"
android:label="Start Game">

<intent-filter>
<action android:name="com.joy.AppA.views.activities.LAUNCH_IT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".views.activities.DashboardActivity" />

</activity>

Then to send data to app a activity from app b, do this:

Intent i = new Intent();
i.setAction("com.joy.AppA.views.activities.LAUNCH_IT");
i.putExtra("gameRecord", gameRecord_array);
startActivity(i);


Related Topics



Leave a reply



Submit