声明可浏览类别后,Android应用程序不再可用
在开发一个非常简单的应用程序时,我在向我的AndroidManifest.xml声明以下行时偶然发现了这种奇怪的行为:声明可浏览类别后,Android应用程序不再可用,android,android-manifest,deep-linking,Android,Android Manifest,Deep Linking,在开发一个非常简单的应用程序时,我在向我的AndroidManifest.xml声明以下行时偶然发现了这种奇怪的行为: <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="com.example.appname" android:host="myHost" /> 基本上,人们可以安装APK,但应用程序
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.example.appname"
android:host="myHost" />
基本上,人们可以安装APK,但应用程序会从菜单中消失,无法再启动。通过设置>应用程序,您可以看到应用程序已安装
所以我创建了一个基本的测试用例,只是一个webview应用程序,只有一个活动加载webview。将其发布到应用商店,如预期的那样,没有问题。推送了一个带有意图类别的更新,同样的问题也出现了。我可以更新到这个新版本,但该应用程序已从主/应用程序屏幕中删除,因此无法启动
完整文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.example.appname"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.example.appname"
android:host="myHost" />
</intent-filter>
</activity>
</application>
当安装在emulator中或通过设备上的ADB时,该应用程序运行良好。可浏览的声明工作正常。您可以为不同的操作声明不同的意图过滤器
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="www.example.com" android:pathPrefix="/prefix" />
</intent-filter>
</activity>
一个活动可以有多个标记。一个用于主/启动器,一个用于可浏览。谢谢,以前从未遇到过这个问题,但这似乎是最好的做法!