问题描述
我已经在我的应用程序中实现了深层链接.我在清单文件中添加了这个意图过滤器,并且深层链接正在工作.
I have implemented deep linking in my app. I added this intent filter in my manifest file, and the deep linking is working.
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.VIEW" />
<data
android:host="www.mywebsite.com"
android:pathPrefix="/something"
android:scheme="http" />
</intent-filter>
问题在于,通过深层链接,我的应用程序正在当前应用程序之上启动.如果我在Gmail中并单击链接,则表明我的应用程序正在Gmail之上启动.我想以不同的方式启动我的应用.
The problem is that through deep linking, my app is launching on top of current app. If I am in Gmail and I click a link, then my app is launching on top of Gmail. I want to launch my app differently.
如果我的应用程序已经在后台运行,并且我单击了Gmail中的链接并重定向到我的应用程序,则我的应用程序将同时运行两个实例;一个在后台,另一个在Gmail顶部.我一次只想运行一个应用程序实例,因此它不在当前应用程序(Gmail)之上.我该怎么办?
If my app is already running in background and I click on a link in Gmail which redirects to my app, I will have two instances of my app running at the same time; one in the background, and another on top of Gmail. I want to run only one instance of my app at a time, so it's not also on top of the current app (Gmail). How can I do that?
推荐答案
已接受的答案对我不起作用,这是做什么的:
the accepted answer didn't work for me, here is what did:
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
来自官方文档:
这篇关于深层链接和多个应用程序实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!