我想知道如何配置我的应用才能使用android-app://application.id
打开它?
adb shell am start android-app://application.id
URI_ANDROID_APP_SCHEME似乎不起作用。相反,Chrome和Firefox仅打开指向我的应用程序的market://
链接。
对于Chrome,我发现a documentation仅描述了intent://
方案。
<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>
您必须在<data../>
中为您的组件添加描述URI的intent-filter
,
<intent-filter>
...
<data android:scheme="android-app"/>
</intent-filter>
并且在您的站点部分上定义这样的意图
intent:#Intent;scheme=android-app;package=your_package;end
更新。尽管我的解决方案适用于您定义的任何方案,但并未意识到该方案是保留方案。我查看了Intent类的来源,看来您必须像这样定义URI
android-app://your_package
OR
android-app://your_package/
#Intent;action=com.example.MY_ACTION;end
Androids Intent类中parseUri
方法的第一行
final boolean androidApp = uri.startsWith("android-app:");
值得一提的是:此方案已在API 22上添加。