In my app, I receive dynamic links within my main activity. This works great when a user opens a link and it launches the app and completes the correct actions, but the dynamic links seems to be staying around after it's been retrieved in the app.
Even after the user has pressed the link and it's retrived in the app with FirebaseDynamicLinks.getInstance().getDynamicLink(getIntent())
, the user could close the app and reopen it some time later and getDynamicLink(getIntent())
would still return the link and the data within the intent.
Is there a way to discard the link & its data once it's been retrieved once in the app? Do I just need to do setIntent(null)
?
Here is my MainActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.ButtonTheme);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
handleDynamicLink();
}
private void handleDynamicLink() {
FirebaseDynamicLinks.getInstance()
.getDynamicLink(getIntent())
.addOnSuccessListener(this, pendingDynamicLinkData -> {
// Get deep link from result (may be null if no link is found)
Uri deepLink = null;
if (pendingDynamicLinkData != null) {
deepLink = pendingDynamicLinkData.getLink();
if(deepLink!=null){
String gameId = deepLink.getQueryParameter("id");
Intent intent = new Intent(this, MultiplayerActivity.class);
intent.putExtra("gameId",gameId);
startMultiplayerActivity(intent);
}
Log.d(TAG, "handleDynamicLink: bundle: "+deepLink.getQueryParameter("id"));
}
}).addOnFailureListener(this, e -> Log.w(TAG, "getDynamicLink:onFailure", e));
}