简体   繁体   English

Android-意图过滤器,用于链接到浏览器外部打开的应用程序

[英]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.

相关问题 即使我的应用程序处理了意图,如何在 Android 上强制在浏览器中打开通用链接 - How to force open a universal link in the browser on Android, even if my app handles the intent Android意图:无论用户使用的是默认浏览器,都在Firefox中打开链接? - Android Intent: Open link in Firefox regardless of user's default browser? 在Android上使用[ionic Mobile App或浏览器]打开链接 - Open Link With [ ionic Mobile App or browser ] on android 通过意图过滤器从浏览器切换到应用时的Android问题 - Android issue when switching from browser to app via intent filter Android PhoneGap意图过滤,浏览器回调正在运行的应用程序? - Android PhoneGap intent-filter, Browser calling back to running app? Android使用Intent Filter打开应用程序链接无效 - Android opening app link using Intent Filter is not working 使用自定义广告系列参数从浏览器意图打开 Android 应用 - Open Android app from browser intent with custom campaign parameter 无法在 Android 应用中打开类似“intent://”的链接 - Can't open link like "intent://" in android app 使用 Intent-filter 从 URL 打开 Android 应用程序不起作用 - Open Android app from URL using intent-filter not working Android:注册意图过滤器以使用我的应用程序打开电子邮件附件 - Android: Registering Intent Filter to open email attachment with my app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM