Same Activity Is Created Twice If You Open From Another App
If you have an APP open in Activity B and you use APP(2) to open the same Activity it will create another instance of Activity B and now you will have 2 Activities B. Is there any
Solution 1:
yes in your manifest use launchMode:singleTask in your activity tag
<activityandroid:name=".MainActivity"android:launchMode="singleTask">
-------------- Your Activity---------
<activity/>
Solution 2:
use in your andorid manifest to make sure that only one instance of activity is created
Solution 3:
Use android:launchMode="singleInstance"
for activity in AndroidManifest
And override onNewIntent
in activity to get data when new startActivity()
called
Solution 4:
Solution 5:
Use below flag before startActivity
Intent intent = newIntent(this, MyActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
And add android:launchMode="singleTask"
for activity tag in your manifest file.
Post a Comment for "Same Activity Is Created Twice If You Open From Another App"