Flutter Android端使用DeepLink时为何需选择应用?
问题:DeepLink唤起应用时出现重复应用选择弹窗
使用DeepLink返回我的应用时,弹出了选择应用的弹窗,但我的应用仅在全新模拟器上安装了一次。(弹窗截图:
)
我已检查AndroidManifest.xml,确认intent-filter未重复配置,相关代码如下:
<activity android:name=".MainActivity" android:launchMode="singleInstance" android:theme="@style/LaunchTheme" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize" android:exported="true"> <!-- Specifies an Android theme to apply to this Activity as soon as the Android process has started. This theme is visible to the user while the Flutter UI initializes. After that, this theme continues to determine the Window background behind the Flutter UI. --> <meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" /> <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.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <!-- Accepts URIs that begin with YOUR_SCHEME://YOUR_HOST --> <data android:scheme="com.myapp.name" android:host="oauth2_redirect" /> </intent-filter> </activity>
排查与解决建议
- 清理模拟器缓存并重装应用:全新模拟器也可能存在缓存残留,卸载应用后清理模拟器存储缓存,再重新安装测试。
- 调整Activity启动模式:
singleInstance模式会让Activity独立占用任务栈,可能导致系统识别异常,尝试改为singleTop或singleTask:android:launchMode="singleTop" - 更换独特的Scheme:部分系统应用或模拟器自带应用可能注册了相同的Scheme,将Scheme修改为更独特的名称,比如
com.myapp.name.oauth。 - 验证DeepLink URI匹配度:确保测试的DeepLink URI完全符合配置(如
com.myapp.name://oauth2_redirect),无多余路径或参数导致匹配异常。 - 再次排查Manifest配置:仔细检查是否有其他Activity或组件注册了相同的Intent Filter,包括Flutter嵌入相关的默认配置。
内容的提问来源于stack exchange,提问作者Matthias Schaffer
相关产品推荐
相关产品推荐

