Android开发之Intent.Action Android中Intent的各种常见作用
1 Intent.ACTION_MAIN
String: android.intent.action.MAIN
标识Activity为一个程序的开始。比较常用。
Input:nothing
Output:nothing
<activity android:name=".Main" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </activity>
2 Intent.Action_CALL
Stirng: android.intent.action.CALL
呼叫指定的电话号码。
Input:电话号码。数据格式为:tel:+phone number
Output:Nothing
Intent intent=new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:1320010001");
startActivity(intent);
3 Intent.Action.DIAL
String: action.intent.action.DIAL
调用拨号面板
Intent intent=new Intent();
intent.setAction(Intent.ACTION_DIAL); //android.intent.action.DIAL
intent.setData(Uri.parse("tel:1320010001");
startActivity(intent);
Input:电话号码。数据格式为:tel:+phone number
Output:Nothing
说明:打开Android的拨号UI。如果没有设置数据,则打开一个空的UI,如果设置数据,action.DIAL则通过调用getData()获取电话号码。
但设置电话号码的数据格式为 tel:+phone number.
4 Intent.Action.ALL_APPS
String: andriod.intent.action.ALL_APPS
列出所有的应用。
Input:Nothing.
Output:Nothing.
5 Intent.ACTION_ANSWER
Stirng:android.intent.action.ANSWER
处理呼入的电话。
Input:Nothing.
Output:Nothing.
6 Intent.ACTION_ATTACH_DATA
String: android.action.ATTCH_DATA
别用于指定一些数据应该附属于一些其他的地方,例如,图片数据应该附属于联系人
Input: Data
Output:nothing
7 Intent.ACTION_BUG_REPORT
String: android.intent.action.BUG_REPORT
显示Dug报告。
Input:nothing
output:nothing
8 Intent.Action_CALL_BUTTON
String: android.action.intent.CALL_BUTTON.
相当于用户按下“拨号”键。经测试显示的是“通话记录”
Input:nothing
Output:nothing
Intent intent = new Intent(Intent.ACTION_CALL_BUTTON);
startActivity(intent);
9 Intent.ACTION_CHOOSER
String: android.intent.action.CHOOSER
显示一个activity选择器,允许用户在进程之前选择他们想要的,与之对应的是Intent.ACTION_GET_CONTENT.
10. Intent.ACTION_GET_CONTENT
String: android.intent.action.GET_CONTENT
允许用户选择特殊种类的数据,并返回(特殊种类的数据:照一张相片或录一段音)
Input: Type
Output:URI
int requestCode = 1001;
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); // "android.intent.action.GET_CONTENT"
intent.setType("image/*"); // 查看类型,如果是其他类型,比如视频则替换成 video/*,或 */*
Intent wrapperIntent = Intent.createChooser(intent, null);
startActivityForResult(wrapperIntent, requestCode);
11 Intent.ACTION_VIEW
String android.intent.action.VIEW
用于显示用户的数据。
比较通用,会根据用户的数据类型打开相应的Activity。
比如 tel:13400010001打开拨号程序,http://www.g.cn则会打开浏览器等。
Uri uri = Uri.parse("http://www.google.com"); //浏览器
Uri uri =Uri.parse("tel:1232333"); //拨号程序
Uri uri=Uri.parse("geo:39.899533,116.036476"); //打开地图定位
Intent it = new Intent(Intent.ACTION_VIEW,uri);
startActivity(it);
//播放视频
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("file:///sdcard/media.mp4");
intent.setDataAndType(uri, "video/*");
startActivity(intent);
//调用发送短信的程序
Intent it = new Intent(Intent.ACTION_VIEW);
it.putExtra("sms_body", "信息内容...");
it.setType("vnd.android-dir/mms-sms");
startActivity(it);
12 Intent.ACTION_SENDTO
//发送短信息
Uri uri = Uri.parse("smsto:13200100001");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
it.putExtra("sms_body", "信息内容...");
startActivity(it);
//发送彩信,设备会提示选择合适的程序发送
Uri uri = Uri.parse("content://media/external/images/media/23");
//设备中的资源(图像或其他资源)
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("sms_body", "内容");
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setType("image/png");
startActivity(it);
Intent intent=new Intent(Intent.ACTION_SEND);
String[] tos={"android1@163.com"};
String[] ccs={"you@yahoo.com"};
intent.putExtra(Intent.EXTRA_EMAIL, tos);
intent.putExtra(Intent.EXTRA_CC, ccs);
intent.putExtra(Intent.EXTRA_TEXT, "The email body text");
intent.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
intent.setType("message/rfc822");
startActivity(Intent.createChooser(intent, "Choose Email Client"));
13 Intent.ACTION_GET_CONTENT
//选择图片 requestCode 返回的标识
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); //"android.intent.action.GET_CONTENT"
intent.setType(contentType); //查看类型 String IMAGE_UNSPECIFIED = "image/*";
Intent wrapperIntent = Intent.createChooser(intent, null);
((Activity) context).startActivityForResult(wrapperIntent, requestCode);
//添加音频
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType(contentType); //String VIDEO_UNSPECIFIED = "video/*";
Intent wrapperIntent = Intent.createChooser(intent, null);
((Activity) context).startActivityForResult(wrapperIntent, requestCode);
//拍摄视频
int durationLimit = getVideoCaptureDurationLimit(); //SystemProperties.getInt("ro.media.enc.lprof.duration", 60);
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, sizeLimit);
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, durationLimit);
startActivityForResult(intent, REQUEST_CODE_TAKE_VIDEO);
//视频
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType(contentType); //String VIDEO_UNSPECIFIED = "video/*";
Intent wrapperIntent = Intent.createChooser(intent, null);
((Activity) context).startActivityForResult(wrapperIntent, requestCode);
//录音
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType(ContentType.AUDIO_AMR); //String AUDIO_AMR = "audio/amr";
intent.setClassName("com.android.soundrecorder",
"com.android.soundrecorder.SoundRecorder");
((Activity) context).startActivityForResult(intent, requestCode);
//拍照 REQUEST_CODE_TAKE_PICTURE 为返回的标识
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //"android.media.action.IMAGE_CAPTURE";
intent.putExtra(MediaStore.EXTRA_OUTPUT, Mms.ScrapSpace.CONTENT_URI); // output,Uri.parse("content://mms/scrapSpace");
startActivityForResult(intent, REQUEST_CODE_TAKE_PICTURE);
Android开发之Intent.Action Android中Intent的各种常见作用的更多相关文章
- Android开发之旅:android架构
本篇将站在顶级的高度——架构,来看android.我开篇就说了,这个系列适合0基础的人且我也是从0开始按照这个步骤来 学的,谈架构是不是有点螳臂挡车,自不量力呢?我觉得其实不然,如果一开始就对整个an ...
- Android开发之assets文件夹中资源的获取
assets中的文件都是保持原始的文件格式,需要使用AssetManager以字节流的形式读取出来 步骤: 1. 先在Activity里面调用getAssets() 来获取AssetManager引用 ...
- Android开发之Eclipse与Android Studio的java类 作者版权模板
/** * 作者:${USER} on ${DATE} ${HOUR}:${MINUTE} * * 联系QQ:986945193 * * 微博:http://weibo.com/mcxiaobing ...
- Android开发之旅: Intents和Intent Filters(理论部分)
引言 大部分移动设备平台上的应用程序都运行在他们自己的沙盒中.他们彼此之间互相隔离,并且严格限制应用程序与硬件和原始组件之间的交互. 我们知道交流是多么的重要,作为一个孤岛没有交流的东西,一定毫无意义 ...
- [置顶] Android开发之MediaPlayerService服务详解(一)
前面一节我们分析了Binder通信相关的两个重要类:ProcessState 和 IPCThreadState.ProcessState负责打开Binder 驱动,每个进程只有一个.而 IPCThre ...
- Android 开发之旅:深入分析布局文件&又是“Hello World!”
http://www.cnblogs.com/skynet/archive/2010/05/20/1740277.html 引言 上篇可以说是一个分水岭,它标志着我们从Android应用程序理论进入实 ...
- Android开发之Intent跳转到系统应用中的拨号界面、联系人界面、短信界面
现在开发中的功能需要直接跳转到拨号.联系人.短信界面等等,查找了很多资料,自己整理了一下. 1.跳转到拨号界面,代码如下: 1)直接拨打 Intent intentPhone = new Intent ...
- android开发之Intent.setFlags()_让Android点击通知栏信息后返回正在运行的程序
android开发之Intent.setFlags()_让Android点击通知栏信息后返回正在运行的程序 在应用里使用了后台服务,并且在通知栏推送了消息,希望点击这个消息回到activity ...
- Android 开发之:Intent.createChooser() 妙用
大家对该功能第一印象就是ApiDemo 里面的 其只有区区几行代码 提取为: Intent intent = new Intent(Intent.ACTION_GET_CONTENT); inten ...
- Android开发之TextView高级应用
Android开发之TextView高级应用 我们平时使用TextView往往让它作为一个显示文字的容器,但TextView的功能并不局限于此.以下就和大家分享一下TextView的一些使用技巧. A ...
随机推荐
- swing之单选框和复选框
import java.awt.Container; import java.awt.GridLayout; import javax.swing.*; public class num_1v ext ...
- nagios添加check_logfiles监控注意事项
为被监控机器添加日志监控,需注意: 1.确认被监控机器/usr/local/nagios/libexec下是否已存在check_logfiles插件,如没有,需要copy进来: 2.确认被监控机器/u ...
- Java基础学习总结(79)——Java本地接口JNI详解
对于java程序员来说,java语言的好处和优点,我想不用我说了,大家自然会说出很多一套套的.但虽然我们作为java程序员,但我们不得不承认java语言也有一些它本身的缺点.比如在性能.和底层打交道方 ...
- 文件处理: read、readline、 readlines()
假设a.txt的内容如下所示: Hello Welcome What is the fuck.. 1. read([size])方法 read([size])方法:从文件当前位置起读取size个字节, ...
- PHP中HTTP_X_FORWARDED_FOR 和 REMOTE_ADDR使用详解
1.REMOTE_ADDR:浏览当前页面的用户计算机的ip地址 2.HTTP_X_FORWARDED_FOR: 浏览当前页面的用户计算机的网关 3.HTTP_CLIENT_IP:客户端的ip 在PHP ...
- Cocoa -- 添加和移除开机启动项
一 写plist到~/Library/LaunchAgents/ 目录下 // 配置开机默认启动 -(void)installDaemon{ NSString* launchFolder = [NSS ...
- DJANGO中如何用邮箱来登陆?
就是另一个不同的登陆backend. 而DJANGO会尝不同的方式,哪个成功就用哪个 authentication.py from django.contrib.auth.models import ...
- 复习es6-解构赋值+字符串的扩展
1. 数组的解构赋值 从数组中获得变量的值,给对应的声明变量赋值,,有次序和对应位置赋值 解构赋值的时候右边必须可以遍历 解构赋值可以使用默认值 惰性求值,当赋值时候为undefined时候,默认是个 ...
- Unix stat
Linux 下有stat命令,可以非常方便的得到一个文件的inode等信息.但是今天在Solaris下使用stat居然没有这个命令.不过没关系,我们可以自己写这个命令,比如: #include < ...
- 【CV论文阅读】Going deeper with convolutions(GoogLeNet)
目的: 提升深度神经网络的性能. 一般方法带来的问题: 增加网络的深度与宽度. 带来两个问题: (1)参数增加,数据不足的情况容易导致过拟合 (2)计算资源要求高,而且在训练过程中会使得很多参数趋向于 ...