Android - Components - Intent

闷骚的程序员

Intent 匹配

使用 PackageManager 返回能接受特定 Intent 的组件

判断是否有 Activity 能处理 Intent

强制使用应用选择器

Intent sendIntent = new Intent(Intent.ACTION_SEND);
...

// Always use string resources for UI text.
// This says something like "Share this photo with"
String title = getResources().getString(R.string.chooser_title);
// Create intent to show the chooser dialog
Intent chooser = Intent.createChooser(sendIntent, title);

// Verify the original intent will resolve to at least one activity
if (sendIntent.resolveActivity(getPackageManager()) != null) {
    startActivity(chooser);
}

点击链接启动其它应用

通过 Intent 实现,需要其它应用注册了对应的 intent-filter,包括 action、category 及 data(schema、host、pathPrefix)和 mimeType 等。

打开系统设置界面

android.provider.Settings类提供android系统各个页面的跳转常量,比如打开“开发者选项”页面:

startActivity(new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS));

Action 列表(有可能需要配合包名类名打开):

Action功能原文
ACTION_ACCESSIBILITY_SETTINGS辅助功能模块的显示设置。Activity Action: Show settings for accessibility modules.
ACTION_ADD_ACCOUNT显示屏幕上创建一个新帐户添加帐户。Activity Action: Show add account screen for creating a new account.
ACTION_AIRPLANE_MODE_SETTINGS显示设置,以允许进入/退出飞行模式。Activity Action: Show settings to allow entering/exiting airplane mode.
ACTION_APN_SETTINGS显示设置,以允许配 置的APN。Activity Action: Show settings to allow configuration of APNs.
ACTION_APPLICATION_DETAILS_SETTINGS有关特定应用程序的详细信息的显示屏幕。Activity Action: Show screen of details about a particular application.
ACTION_APPLICATION_DEVELOPMENT_SETTINGS显示设置,以允许应用程序开发相关的设置配置Activity Action: Show settings to allow configuration of application development-related settings.
ACTION_APPLICATION_SETTINGS显示设置,以允许应用程序相关的设置配置Activity Action: Show settings to allow configuration of application-related settings.
ACTION_BLUETOOTH_SETTINGS显示设置,以允许蓝牙配置Activity Action: Show settings to allow configuration of Bluetooth.
ACTION_DATA_ROAMING_SETTINGS选择of2G/3G显示设置Activity Action: Show settings for selection of2G/3G.
ACTION_DATE_SETTINGS显示日期和时间设置,以允许配 置Activity Action: Show settings to allow configuration of date and time.
ACTION_DEVICE_INFO_SETTINGS显示一般的设备信息设置(序列号,软件版本,电话号码,等)Activity Action: Show general device information settings (serial number, software version, phone number, etc.).
ACTION_DISPLAY_SETTINGS显示设置,以允许配 置显示Activity Action: Show settings to allow configuration of display.
ACTION_INPUT_METHOD_SETTINGS特别配置的输入方法,允许用户启用输入法的显示设置Activity Action: Show settings to configure input methods, in particular allowing the user to enable input methods.
ACTION_INPUT_METHOD_SUBTYPE_SETTINGS显示设置来启用/禁用输入法亚型Activity Action: Show settings to enable/disable input method subtypes.
ACTION_INTERNAL_STORAGE_SETTINGS内部存储的显示设置Activity Action: Show settings for internal storage.
ACTION_LOCALE_SETTINGS显示设置,以允许配 置的语言环境Activity Action: Show settings to allow configuration of locale.
ACTION_LOCATION_SOURCE_SETTINGS显示设置,以允许当前位置源的配置Activity Action: Show settings to allow configuration of current location sources.
ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS显示设置来管理所有的应用程序Activity Action: Show settings to manage all applications.
ACTION_MANAGE_APPLICATIONS_SETTINGS显示设置来管理安装的应用程序Activity Action: Show settings to manage installed applications.
ACTION_MEMORY_CARD_SETTINGS显示设置为存储卡存储Activity Action: Show settings for memory card storage.
ACTION_NETWORK_OPERATOR_SETTINGS选择网络运营商的显示设置Activity Action: Show settings for selecting the network operator.
ACTION_PRIVACY_SETTINGS显示设置,以允许配 置隐私选项Activity Action: Show settings to allow configuration of privacy options.
ACTION_QUICK_LAUNCH_SETTINGS显示设置,以允许快速启动快捷键的配置Activity Action: Show settings to allow configuration of quick launch shortcuts.
ACTION_SEARCH_SETTINGS全局搜索显示设置Activity Action: Show settings for global search.
ACTION_SECURITY_SETTINGS显示设置,以允许配 置的安全性和位置隐私Activity Action: Show settings to allow configuration of security and location privacy.
ACTION_SETTINGS显示系统设置Activity Action: Show system settings.
ACTION_SOUND_SETTINGS显示设置,以允许配 置声音和音量Activity Action: Show settings to allow configuration of sound and volume.
ACTION_SYNC_SETTINGS显示设置,以允许配 置同步设置Activity Action: Show settings to allow configuration of sync settings.
ACTION_USER_DICTIONARY_SETTINGS显示设置来管理用户输入字典Activity Action: Show settings to manage the user input dictionary.
ACTION_WIFI_IP_SETTINGS显示设置,以允许配 置一个静态IP地址的Wi – FiActivity Action: Show settings to allow configuration of a static IP address for Wi-Fi.
ACTION_WIFI_SETTINGS显示设置,以允许Wi – Fi配置Activity Action: Show settings to allow configuration of Wi-Fi.
ACTION_WIRELESS_SETTINGS显示设置,以允许配 置,如Wi – Fi,蓝牙和移动网络的无线控制Activity Action: Show settings to allow configuration of wireless controls such as Wi-Fi, Bluetooth and Mobile networks.
AUTHORITY  
EXTRA_AUTHORITIES在推出活动的基础上给予的权力限制可选项。Activity Extra: Limit available options in launched activity based on the given authority.
EXTRA_INPUT_METHOD_ID  

参考

文档信息

Search

    Table of Contents