Android – how do I use explicit intent to pass URIs?

I want to use expand to launch a specific number on the softphone application. The implicit application looks like:

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

Launching a clear application looks like:

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

Question: can I use explicit intent to pass URI and use action_ Call launch application?

resolvent:

Yes. Using your example, you can do the following:

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

When you use explicit intent, Android will not use the action or data fields in intent to determine the activity to start. You have explicitly set this value in intent. However, you can still set the action and data fields in intent to pass information to the activity you are starting

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>