dev90
dev90

Reputation: 7519

App crashes on opening deep link from the app

I have a requirement where i need to launch the deep link from the app.

This is my deep link.

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

Now when i try to open this link from app, it crashes with following error message.

No Activity found to handle Intent : android.intent.action.VIEW

Code:

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

Upvotes: 2

Views: 1481

Answers (2)

siddharth.prakash
siddharth.prakash

Reputation: 29

There is no browser app in the device to open the link. To handle this issue:

Resolve beforehand if an app exists:

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

Handle with exception:

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

or alternatively open in webview activity to display.

Upvotes: 1

akashzincle
akashzincle

Reputation: 1128

Make sure to make update an Activity to handle deeplinks, in AndroidManifest you have added IntentFilter with Viewable action.

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

Upvotes: 0

Related Questions