I have implemented a DeeplinkActivity to catch the intent-filter data scheme and open an activity. The issue I am having is the app is already open in the background and then the user clicks a deep link to open the home screen activity. If the user presses back to get out of the app it will go to what was running in the background. I wanted it to just back out of the app.
I have tried this.
Intent intent = new Intent(this, LaunchActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
But this does not work. Any suggestions?
I have just had this problem fixed myself.
First you need to go to the manifest and set launchMode to "singleTask", this will prevent your app from opening a new instance entirely.
Second you need to go the Activity that's accepting that intent filter and override this method
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
}
now by using the new intent here you will have access to the deep link and be able to route to where you need to within your app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With