In B’s manifest as below:
<activity android:name="BActivity" >
<intent-filter>
<action android:name="ACTION_TEST" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
And had a Global variable.
In A’s launch code as below:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("package name","package name.BActivity"));
startActivity(intent);
It can launch B_app successly.
But while I launch B from A and direct launch B by click B’s icon, the Global variable are the same between them.
I want to B launched from A and launched directly are 2 independent app.
How can I do it?
When you leaunch your Activity B from A you could pass some boolean to B stating that it has been launched from A. For Example launch your activity A from B as follows:
And in your Activity B then you check if you have any bundle in
onCreate()as followsIf it is launched from the launcher then you can clear away the global variables.