Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to enable deep linking to android app, testing intent can't launch activity

I'm trying to enable deep linking so that certain links launch my app.

I read this turotial https://developer.android.com/training/app-indexing/deep-linking.html and following it pretty close but when I try to test it by using adb to send the VIEW intent to the app I just get the error

Error: Activity not started, unable to resolve Intent { act=android.intent.actio
n.VIEW dat=example://gizmos flg=0x10000000 pkg=com.myapp.DeepLinkActivity }

DeepLinkActivity.java

public class DeepLinkActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (getIntent().getAction() == Intent.ACTION_VIEW) {
        Uri uri = getIntent().getData();

    }

  }
}

Android Manifest declaring deeplink activity

<activity android:name="com.myapp.DeepLinkActivity" >
        <intent-filter>

            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />


            <data
                android:host="gizmos"
                android:scheme="example" />
            <!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
            <data
                android:host="www.example.com"
                android:pathPrefix="gizmos"
                android:scheme="http" />
        </intent-filter>
    </activity>

ADB command to send the view intent

adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.myapp.DeepLinkActivity

But I don't think I even need the full path to the activity

adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.myapp
like image 624
Brian Avatar asked Sep 08 '14 22:09

Brian


2 Answers

Try skipping package param entirely. I had exactly same problem and it works.

adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos"

like image 189
Kamil Sarna Avatar answered Oct 16 '22 20:10

Kamil Sarna


Comment out the second data part from your Android Manifest. As per google documentation of deep link :

"Intent filters may only contain a single data element for a URI pattern. Create separate intent filters to capture additional URI patterns."

like image 35
Nikhil Gupta Avatar answered Oct 16 '22 22:10

Nikhil Gupta