1

i'm exploring the Intent world of android programing and found out

Intent sendIntent = new Intent(Intent.ACTION_MAIN);         
        sendIntent.setData(Uri.parse(xxx));

I heard that ACTION_MAIN could open other app, if so, what should i fill the xxx on the setData part?

Fay
  • 49
  • 1
  • 9

1 Answers1

1

You are having some misconception here,

ACTION_MAIN

Above one is used to define entry point of an Application which requires no input and have no output.

See official documentation

public static final String ACTION_MAIN

Added in API level 1
Activity Action: Start as a main entry point, does not expect to receive data.

Input: nothing

Output: nothing

Constant Value: "android.intent.action.MAIN"

Now for your query to open another application,

There are several ways but in any case you need to know the package name of the another application to launch.

Well know and most commonly used ways are in this answer with top rated below one,

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
startActivity(launchIntent);
Community
  • 1
  • 1
MKJParekh
  • 34,073
  • 11
  • 87
  • 98