【问题标题】:App crashes on opening deep link from the app从应用打开深层链接时应用崩溃
【发布时间】:2020-04-13 14:46:19
【问题描述】:

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

这是我的深层链接。

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

现在,当我尝试从应用打开此链接时,它会崩溃并显示以下错误消息。

未找到处理 Intent 的 Activity:android.intent.action.VIEW

代码:

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

【问题讨论】:

    标签: android android-webview


    【解决方案1】:

    确保更新 Activity 以处理深层链接,在 AndroidManifest 中您已添加 IntentFilter 和 Viewable 操作。

      <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>
    

    【讨论】:

      【解决方案2】:

      设备中没有可以打开链接的浏览器应用。处理这个问题:

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

      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 
      }
      

      或者在 webview 活动中打开以显示。

      【讨论】:

        猜你喜欢
        • 2016-10-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-01-08
        • 1970-01-01
        • 1970-01-01
        • 2016-05-10
        • 1970-01-01
        相关资源
        最近更新 更多