从应用程序打开深度链接时应用程序崩溃



我有一个需求,需要从应用程序启动深度链接。

这是我的深层联系。

https://n9zv0.app.link/63yWc1w1

现在,当我试图从应用程序打开这个链接时,它崩溃了,并显示以下错误消息。

未找到处理意向的活动:android.Intent.action.VIEW

代码:

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://o5kn2.app.link/63yW7yM7C5"));
startActivity(browserIntent);

设备中没有用于打开链接的浏览器应用程序。处理此问题:

如果应用程序存在,请提前解决:

if (intent.resolveActivity(getPackageManager()) == null) {
// show no app available to user
} else {
// start activity
}

异常处理:

try{
// your intent here
} catch (ActivityNotFoundException e) {
// show message to user 
}

或者可替换地在web视图活动中打开以进行显示。

确保更新活动以处理深度链接,在AndroidManifest中,您添加了具有Viewable操作的IntentFilter。

<activity
android:name=".MyActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.abc.com"
android:scheme="https" />
<data
android:host="www.abc.com"
android:scheme="http" />
</intent-filter>
</activity>

最新更新