Issue
I am starting an Activity from other application using the following custom action :
Intent intent = new Intent();
intent.setAction("some.custom.action.ACTION");
startActivity(intent)
and i am able to start the activity, i have registered the same action in menifest of my application as below :
<activity
android:name=".TestActivity"
android:exported="true">
<intent-filter>
<action android:name="some.custom.action.ACTION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
now the problem is when my (TestActivity) activity is running i am not able to start it again using same method. I need to restart that activity(TestActivity) again when other application tries to start my activity(TestActivity).
i tried android:launchMode="singleTop"
but it is not doing the trick.
i am getting the following warning:
Warning: Activity not started, intent has been delivered to currently running top-most instance
but i am not sure how to get this intent in my app.
thanks in advance
Solution
finally i resolved this by adding android:launchMode="singleTop"
in activity tag and adding flag in intent Intent.FLAG_ACTIVITY_CLEAR_TOP
after that i got new intent in
@Override
protected void onNewIntent(Intent intent){}
final Activity tag:
<activity
android:launchMode="singleTop"
android:name=".TestActivity"
android:exported="true">
<intent-filter>
<action android:name="some.custom.action.ACTION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
final intent :
Intent intent = new Intent();
intent.setAction("some.custom.action.ACTION");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(intent)
Answered By - Manmohan Chauhan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.