[英]Android - intent filter for link to open app OUTSIDE of browser
I have successfully set up an intent-filter in my Android app to open the app from the mobile browser based on one of many SO posts on this topic . 我已成功在Android应用程序中设置了一个意图过滤器,以根据有关此主题的众多SO帖子之一从移动浏览器中打开该应用程序。
However, the problem is that the native app is opening WITHIN the browser, when I rather want it to open OUTSIDE of the browser in a separate app process. 但是,问题是本机应用程序正在浏览器中打开,而我希望它在一个单独的应用程序进程中在浏览器的外部打开。
By WITHIN, I mean that when I press the rightmost 'active apps' button to see what is running, I see that my current app is still the browser app, and there is no separate app opened called MyApp. 通过WITHIN,我的意思是当我按下最右边的“活动应用程序”按钮查看正在运行的程序时,我看到我当前的应用程序仍是浏览器应用程序,并且没有打开名为MyApp的单独应用程序。 It is as if the browser embeds my native app within itself, and so the browser is executing my app process.
就像浏览器将我的本机应用程序嵌入其中一样,因此浏览器正在执行我的应用程序进程。
And by OUTSIDE, I mean that I want to be able to see two active apps running after I press the link: (1) the browser app from which I launched (2) my MyApp app. 另外,我的意思是,我希望在按下链接后能够看到两个活动的应用程序正在运行:(1)启动我的浏览器应用程序(2)MyApp应用程序。
This is my intent-filter set up in AndroidManifest.xml: 这是我在AndroidManifest.xml中设置的意图过滤器:
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data android:scheme="myapp" android:host="mypath" />
</intent-filter>
And I link to this from a web page opened in the browser using: 我从浏览器中打开的网页使用以下链接:
<a href="myapp://mypath">Open app</a>
How can I force the app to open OUTSIDE of the browser? 如何强制应用打开浏览器的外部? One note is that when the app launches I don't see an 'app chooser' which I've seen for other apps.
需要注意的是,当应用启动时,我看不到其他应用看到的“应用选择器”。
By WITHIN, I mean that when I press the rightmost 'active apps' button to see what is running, I see that my current app is still the browser app, and there is no separate app opened called MyApp.
通过WITHIN,我的意思是当我按下最右边的“活动应用程序”按钮查看正在运行的程序时,我看到我当前的应用程序仍是浏览器应用程序,并且没有打开名为MyApp的单独应用程序。
Your activity was launched within the browser's task . 您的活动是在浏览器的Task中启动的。
It is as if the browser embeds my native app within itself and itself is executing my app process.
好像浏览器将我的本机应用程序嵌入其内部并且其本身正在执行我的应用程序过程。
That is not what is happening. 那不是正在发生的事情。
How can I force the app to open OUTSIDE of the browser?
如何强制应用打开浏览器的外部?
If you mean that you want the activity to appear in a separate task... ideally, that would happen by default. 如果您要让活动显示在单独的任务中...理想情况下,默认情况下会发生这种情况。 I'm surprised that a browser would not have added
FLAG_ACTIVITY_NEW_TASK
when it started your activity. 我很惊讶浏览器在开始活动时没有添加
FLAG_ACTIVITY_NEW_TASK
。
That being said, android:launchMode="singleTask"
on your <activity>
element should give you the desired behavior. 话虽这么说,
<activity>
元素上的android:launchMode="singleTask"
应该会为您提供所需的行为。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.