Issue
I get an intent when I am in my main activity,
if (getIntent() != null &&
LinkReceiver.LINK_INTENT.equals(getIntent().getAction())) {
Uri appLinkData = getIntent().getData();
if (appLinkData != null) {
processIntent(appLinkData);
}
}
I have this in the onStart
method. I use startActivity()
to navigate to another activity
. When I press back on the second activity that I am on, I return back to the main activity
, but the intent never becomes null.
I have tried doing setIntent(null)
in the processIntent
method, I have tried doing getIntent.setAction("")
and getIntent.setData(null)
.
Is there any way to do this without overriding the onBackPressed()
method in the second activity to open the main activity again without an intent.
Solution
getIntent()
will always return the Intent
that the Activity
was launched with. Why not just set a flag in your MainActivity
when you call startActivity()
for the other Activity
. When it returns to your Activity
you can check the flag to determine the state and act accordingly.
Alternatively you can use startActivityForResult()
which will allow you to pass information back from the Activity
you launched. Also the method onActivityResult()
will get called on your MainActivity
when the other Activity
completes, so you can set internal flags or whatever to determine what to do next.
Answered By - David Wasser
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.