安卓系统常用Action
在本文中,主要介绍常见action的使用,Action描述Intent所触发动作名字的字符串,对于BroadcastIntent来说,Action指被广播出去的动作。理论上Action可 以为任何字符串,而与Android系统应用有关的Action字符串以静态字符串常量的形式定义在了Intent类中。Action中包含很多种,例如呼入,呼出电话,老师上课讲的接受短信等等,下面谨对常见的与系统有关的action进行整理:
1. Intent.ACTION_MAIN
String: android.intent.action.MAIN
标识Activity为一个程序的开始。
2. Intent.Action_CALL
Stirng: android.intent.action.CALL
呼叫指定的电话号码。
Intent intent=new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:10086");
startActivity(intent);
3. Intent.ACTION_POWER_CONNECTED;
插上外部电源时发出的广播
4 Intent.ACTION_POWER_DISCONNECTED;
已断开外部电源连接时发出的广播
5.Intent.Action.DIAL
String: action.intent.action.DIAL
调用拨号面板
Intent intent=new Intent();
intent.setAction(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:10086");
startActivity(intent);
6.Intent.Action.ALL_APPS
String: andriod.intent.action.ALL_APPS
列出所有的应用。
7.Intent.ACTION_ANSWER
Stirng:android.intent.action.ANSWER
处理呼入的电话。
8 .Intent.ACTION_BUG_REPORT
String: android.intent.action.BUG_REPORT
显示Dug报告。
9. Intent.Action_CALL_BUTTON
String: android.action.intent.CALL_BUTTON.
相当于按“拨号”键。
Intent intent = new Intent(Intent.ACTION_CALL_BUTTON);
startActivity(intent);
10. Telephony.SMS_RECEIVED
String: android.provider.Telephony.SMS_RECEIVED
接收短信的action
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
<data android:host="localhost"/>
</intent-filter>
11. Intent.ACTION_GET_CONTENT
String: android.intent.action.GET_CONTENT
允许用户选择特殊种类的数据,并返回(特殊种类的数据:照一张相片或录一段音)
12. Intent.ACTION_BATTERY_LOW;
String: android.intent.action.BATTERY_LOW
表示电池电量低
13. Intent.ACTION_SEND
String: android.intent.action.Send
发送邮件的action
14. Intent.ACTION_CALL_PRIVILEGED
String:android.intent.action.CALL_PRIVILEGED
调用skype的action
Intent intent = newIntent("android.intent.action.CALL_PRIVILEGED");
intent.setClassName("com.skype.raider",
"com.skype.raider.Main");
intent.setData(Uri.parse("tel:" + phone));
startActivity(intent);
15. Intent.ACTION_CLOSE_SYSTEM_DIALOGS
当屏幕超时进行锁屏时,当用户按下电源按钮,长按或短按(不管有没跳出话框),进行锁屏时,android系统都会广播此Action消息