How to launch an application using deeplink in android

I want to start the application using my own application, but without specifying the package name, I want to open my own URL.

I do this to run the application.

Intent intent = getPackageManager().getLaunchIntentForPackage(packageInfo.packageName); startActivity(intent); 

Instead of the package name, you can give a deep link, for example:

 "mobiledeeplinkingprojectdemo://product/123" 

Link

+6
source share
1 answer

You need to determine the action that will be subscribed to the required intent filters:

 <activity android:name="DeepLinkListener" android:exported="true" > <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="host" android:pathPattern="some regex" android:scheme="scheme" /> </intent-filter> </activity> 

Then in onCreate of your DeepLinkListener action you can access the host, circuit, etc:

 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent deepLinkingIntent= getIntent(); deepLinkingIntent.getScheme(); deepLinkingIntent.getData().getPath(); } 

perform a check along the way and re-launch the intention to take the user to the appropriate action. data for more help

Now run the intent:

 Intent intent = new Intent (Intent.ACTION_VIEW); intent.setData (Uri.parse(DEEP_LINK_URL)); 
+9
source

Source: https://habr.com/ru/post/974970/


All Articles