Android常用的intent action汇总_Android

本文总结讲述了Android常用的intent action功能。分享给大家供大家参考,具体如下:

Android基本的设计理念是鼓励减少组件间的耦合,因此Android提供了Intent (意图) ,Intent提供了一种通用的消息系统,它允许在你的应用程序与其它的应用程序间传递Intent来执行动作和产生事件。Intent作为联系各Activity之间的纽带,其作用并不仅仅只限于简单的数据传递。通过其自带的属性,其实可以方便的完成很多较为复杂的操作。例如直接调用拨号功能、处理接收短信,诸如此类,都可以通过设置Intent属性来完成。

Intent主要有以下四个重要属性,它们分别为:

Action:Action属性的值为一个字符串,它代表了系统中已经定义了一系列常用的动作。通过setAction()方法或在清单文件AndroidManifest.xml中设置。标识Activity为一个程序开始的示例代码(AndroidManifest.xml进行配置)如下:

<span style="font-size:16px;">
<intent-filter>
  <action android:name="android.intent.action.MAIN" />
  <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</span>

Data:Data通常是URI格式定义的操作数据。例如:tel:// 。通过setData()方法设置。
Category:Category属性用于指定当前动作(Action)被执行的环境。通过addCategory()方法或在清单文件AndroidManifest.xml中设置。默认为:CATEGORY_DEFAULT。
Extras:Extras属性主要用于传递目标组件所需要的额外的数据。通过putExtras()方法设置。

在本文中,主要介绍常见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消息

以上是对常见的action进行总结,action其实有很多,如果要使用上文没有列举到的,google即可。

更多关于Android相关内容感兴趣的读者可查看本站专题:《Android编程之activity操作技巧总结》、《Android资源操作技巧汇总》、《Android文件操作技巧汇总》、《Android操作SQLite数据库技巧总结》、《Android操作json格式数据技巧总结》、《Android数据库操作技巧总结》、《Android编程开发之SD卡操作方法汇总》、《Android开发入门与进阶教程》、《Android视图View技巧总结》及《Android控件用法总结》

希望本文所述对大家Android程序设计有所帮助。

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索android
, action
intent
intent action、intent.setaction、intent.action view、intent.getaction、intent filter action,以便于您获取更多的相关知识。

时间: 2024-08-30 18:00:12

Android常用的intent action汇总_Android的相关文章

Android常用的intent action汇总

本文总结讲述了Android常用的intent action功能.分享给大家供大家参考,具体如下: Android基本的设计理念是鼓励减少组件间的耦合,因此Android提供了Intent (意图) ,Intent提供了一种通用的消息系统,它允许在你的应用程序与其它的应用程序间传递Intent来执行动作和产生事件.Intent作为联系各Activity之间的纽带,其作用并不仅仅只限于简单的数据传递.通过其自带的属性,其实可以方便的完成很多较为复杂的操作.例如直接调用拨号功能.处理接收短信,诸如此

Android开发中Intent用法总结_Android

本文实例讲述了Android开发中Intent用法.分享给大家供大家参考,具体如下: Android手机软件开发中,Intent作为手机软件开发时很重要的对象需要引起我们的重视,实际上,intent也是体现Android开发具有其独特性的一个标志性的对象. 当一个Activity要启动另外一个Activity的时候,也许一个以前较为熟悉的模式是:调用一个new函数,直接创建具有窗口特征类的对象,又或者直接调用一个启动函数来启动.这种方式简洁.明了,但是却违背了Android开发的理念.Andro

Android 去掉状态栏的方法汇总_Android

在实际的应用程序开发中,我们有时需要把 Activity 设置成全屏显示,一般情况下,可以通过两种方式来设置全屏显示效果: 其一,通过在代码中可以设置, 其二,通过manifest配置文件来设置全屏. 其一:在代码onCreate里面setContentView之前设置(如下) view plaincopy to clipboardprint? public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstan

Android 更新UI的方法汇总_Android

1.Activity的 runOnUiThread textView = (TextView) findViewById( R.id.tv ); new Thread(new Runnable() { @Override public void run() { runOnUiThread(new Runnable() { @Override public void run() { textView.setText( "更新UI了"); } }); } }).start(); andro

34个Android常用adb shell命令汇总

调试Android程序有时需要adb shell 命令,adb全称Android Debug Bridge ,就是起到调试桥的作用.通过adb我们可以在Eclipse中通过DDMS来调试Android程序,说白了就是debug工具.adb通过监听Socket TCP 5554等端口让IDE和Qemu通讯.默认情况下当我们运行Eclipse时adb进程就会自动运行.adb是一个C/S模式的程序,由三个部分组成:a client,a server and a daemon.其中client和serv

Android 屏幕截屏方法汇总_Android

1.直接使用getWindow().getDecorView().getRootView() 直接使用getWindow().getDecorView().getRootView()是获取当前屏幕的activity.然而对于系统状态栏的信息是截不了,出现一条空白的.如下图:   主要到没,有一条白色边就是系统状态栏.看一下代码,很简单都加了注释了. //这种方法状态栏是空白,显示不了状态栏的信息 private void saveCurrentImage() { //获取当前屏幕的大小 int

基于android中权限的集合汇总_Android

程序执行需要读取到安全敏感项必需在androidmanifest.xml中声明相关权限请求, 完整列表如下: 1. android.permission.ACCESS_CHECKIN_PROPERTIES    允许读写访问"properties"表在 checkin数据库中,改值可以修改上传( Allows read/write access to the "properties" table in the checkin database, to change

Android常用进度条效果分享_Android

先看看效果: activity_main.xml主页布局就2个button,分别弹出不同效果的2个进度条 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layou

android 支持的语言列表(汇总)_Android

Arabic, Egypt (ar_EG) -----------------------------阿拉伯语,埃及Arabic, Israel (ar_IL) -------------------------------阿拉伯语,以色列Bulgarian, Bulgaria (bg_BG) ---------------------保加利亚语,保加利亚Catalan, Spain (ca_ES) ---------------------------加泰隆语,西班牙Czech, Czech