Launch application from another using a deeplink

The above answer can only open the app with screen defined as LAUNCHER, not with deep link.

This will work to link app XYZ with any app:

 private void startAppXYZfromThisFuckinApp() {
   // pass the uri (scheme & screen path) of a screen defined from app XXX that you want to open (e.g HomeActivity)
   Uri uri = Uri.parse("xyz://screen/home");
   Intent mapIntent = new Intent(Intent.ACTION_VIEW, uri);

  //Verify if app XYZ has this screen path
    PackageManager packageManager = getPackageManager();
    List<ResolveInfo> activities = 
    packageManager.queryIntentActivities(mapIntent, 0);
    boolean isIntentSafe = activities.size() > 0;

   //Start HomeActivity of app XYZ because it's existed
    if (isIntentSafe) {
        startActivity(mapIntent);
    }
 }

And obviously, in app XYZ AndroidManifest.xml must be something like this:

<activity
 android:name=".HomeActivity"
 <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="screen/home"
   android:scheme="xyz" />
 </intent-filter>
   

It will now open screen HomeActivity from app XYZ!


Try to create the Intent from PackageManager and set the action (ACTION_VIEW) and the data (myAction) before launching deepLink:

    Uri myAction = Uri.parse(mEditText.getText().toString());

    PackageManager packageManager = getPackageManager();
    Intent intent = packageManager.getLaunchIntentForPackage(<app_destination_package>);

    if (intent != null) {
        intent.setAction(Intent.ACTION_VIEW);
        intent.setData(myAction);
        startActivity(intent);
    }

Change your manifest like this

<data
    android:host="open"
    android:pathPattern="/myAction?param=123"
    android:scheme=" myApp" />

To send an intent in the first activity

Intent intent = new Intent (Intent.ActionView);
intent.setData (Uri.Parse (DEEP_LINK_URL));

And in your second activity

if(getIntent()!=null){
    Intent deepLink = getIntent();
    deepLink.getScheme();
    deepLink.getData().getPath();   
}