6

Deep Linking Android first opens the launcher activity (not the deeply linked activity ) then the deeply linked activity as declared in Manifest file.I have followed all the steps mentioned here .

viz. Manifest contains

<activity
    android:name="com.example.android.GizmosActivity"
    android:label="@string/title_gizmos" >
    <intent-filter android:label="@string/filter_title_viewgizmos">
        <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 "http://www.example.com/gizmos” -->
        <data android:scheme="http"
              android:host="www.example.com"
              android:pathPrefix="/gizmos" />
        <!-- note that the leading "/" is required for pathPrefix-->
        <!-- Accepts URIs that begin with "example://gizmos”
        <data android:scheme="example"
              android:host="gizmos" />
        -->
    </intent-filter>
</activity>

and Deeply Linked activity contains

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Intent intent = getIntent();
    String action = intent.getAction();
    Uri data = intent.getData();
}

and some other activity specific code.

Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182
Mohammad Khan
  • 571
  • 5
  • 13

2 Answers2

0

I had this same problem and in my case it was simply a copy and pasting issue. make sure your deep links intent filters ONLY exist under the right activity in the manifest. if you have 2 identical filters under 2 different activities, it will open the first one (logically your main activity would be your first one)

user3453281
  • 559
  • 5
  • 12
0

Just remove android:label="@string/filter_title_viewgizmos" from intent filter. Your code will start working.

Thanks.

Sulabh Jain
  • 342
  • 1
  • 9