在开发一个非常简单的应用程序时,我在向 AndroidManifest.xml 声明以下行时偶然发现了这种奇怪的行为:
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.example.appname"
android:host="myHost" />
Run Code Online (Sandbox Code Playgroud)
基本上人们可以安装 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>
Run Code Online (Sandbox Code Playgroud)
当安装在模拟器中或通过设备上的 ADB 安装时,该应用程序运行良好。可浏览的声明工作正常。