Passing data between two android apps using intent

前端 未结 2 1347
臣服心动
臣服心动 2021-01-13 16:43

I have two separate android apps, AppA and AppB. I am trying to get AppA to launch AppB (which is a game app). After the user is done playing the game (AppB), it will send t

相关标签:
2条回答
  • 2021-01-13 17:09

    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);
    
    0 讨论(0)
  • 2021-01-13 17:24

    Maybe it can be useful:

    Content Provider and Content Resolver components.

    Content Resolver makes request to Content Provider, and the provider respond. This is similar to a communication between two different applications.

    For example a client (Resolver) and a content manager(Provider).

    This is an example tutorial: https://www.tutorialspoint.com/android/android_content_providers.htm

    Hope it helps!

    0 讨论(0)
提交回复
热议问题