How to pass URIs with explicit intent?

I would like to use the explication intent to run a specific number in the softphone application. An implicit application will look like this:

Intent callIntent = new Intent(Intent.ACTION_CALL);
    callIntent.setData(Uri.parse(phone));
    startActivity(callIntent);

Running an explicit application looks something like this:

Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("example.app");
    startActivity(LaunchIntent);

Question: Is it possible to pass Uri and run the application with ACTION_CALL using explicit intent?

+4
source share
1 answer

Yes. Using your example, you can do this:

Intent intent = getPackageManager().getLaunchIntentForPackage("example.app");
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse(phone));
startActivity(LaunchIntent);

Intent, Android ACTION DATA Intent Activity. Intent. ACTION DATA Intent Activity, .

+3

All Articles