隐含意图

隐式意图不命名特定组件,而是声明要执行的常规操作,这允许来自另一个应用程序的组件处理它。

例如,如果要向用户显示地图上的位置,则可以使用隐式意图请求另一个有能力的应用程序在地图上显示指定位置。

例:

// Create the text message with a string
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);
sendIntent.setType("text/plain");

// Verify that the intent will resolve to an activity
if (sendIntent.resolveActivity(getPackageManager()) != null) {
    startActivity(sendIntent);
}