繁体   English   中英

在 Android 上使用 Chrome 打开 android-app 方案

[英]Open android-app scheme with Chrome on Android

我想知道我必须如何配置我的应用程序才能使用android-app://application.id打开它?

adb shell am start android-app://application.id

URI_ANDROID_APP_SCHEME似乎不像文档那样工作。 相反,Chrome 和 Firefox 只打开一个market://链接到我的应用程序。

对于 Chrome,我找到了一个仅描述intent://方案的文档

当意图过滤器包含DEFAULTBROWSABLE类别时,它适用于Firefox

<intent-filter>
    <action android:name="android.intent.action.MAIN" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.LAUNCHER" />
    <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

你必须在你的组件的intent-filter添加<data../>描述 URI,像这样,

<intent-filter>
   ...

   <data android:scheme="android-app"/>
</intent-filter>

并在您的网站部分定义这样的意图

intent:#Intent;scheme=android-app;package=your_package;end

更新。 没有意识到该方案是保留方案,尽管我的解决方案适用于您定义的任何方案。 我查找了 Intent 类的来源,似乎您必须像这样定义 URI

android-app://your_package

或者

android-app://your_package/ 
#Intent;action=com.example.MY_ACTION;end

Androids Intent 类中parseUri方法的第一行

final boolean androidApp = uri.startsWith("android-app:");

值得一提的是:这个方案是在 API 22 上添加的。

我已经测试过它可以与标签一起a ,并且正如@tynn 在评论中提到的那样,也适用于window.open()location.href并且不能在 Chrome 的地址栏中工作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM