Android intent.Action 参数值及对应功能介绍(转)

在博客园看到一篇写的比较详细文章,转来分享下,也便于自己用到时查询 

1 Intent.ACTION_MAIN 
String: android.intent.action.MAIN 
标识Activity为一个程序的开始。比较常用。 
Input:nothing 
Output:nothing 

Xml代码  
  1. <activity android:name=".Main" android:label="@string/app_name">     
  2. <intent-filter>  
  3.          <action android:name="android.intent.action.MAIN" />  
  4.          <category android:name="android.intent.category.LAUNCHER" />  
  5.      </intent-filter>  
  6. </activity>   


2 Intent.Action_CALL 
Stirng: android.intent.action.CALL 
呼叫指定的电话号码。 
Input:电话号码。数据格式为:tel:+phone number 
Output:Nothing 

Java代码  
  1. Intent intent=new Intent();   
  2. intent.setAction(Intent.ACTION_CALL);     
  3. intent.setData(Uri.parse("tel:1320010001");  
  4. startActivity(intent);  


3 Intent.Action.DIAL 
String: action.intent.action.DIAL 
调用拨号面板 
Input:电话号码。数据格式为:tel:+phone number 
Output:Nothing 
说明:打开Android的拨号UI。如果没有设置数据,则打开一个空的UI,如果设置数据,action.DIAL则通过调用getData()获取电话号码。 
但设置电话号码的数据格式为 tel:+phone number. 

Java代码  
  1. Intent intent=new Intent();  
  2. intent.setAction(Intent.ACTION_DIAL);   //android.intent.action.DIAL  
  3. intent.setData(Uri.parse("tel:1320010001");  
  4. startActivity(intent);   


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 

Java代码  
  1. Intent intent = new Intent(Intent.ACTION_CALL_BUTTON);  
  2. 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 

Java代码  
  1. int requestCode = 1001;  
  2. Intent intent = new Intent(Intent.ACTION_GET_CONTENT); // "android.intent.action.GET_CONTENT"  
  3. intent.setType("image/*"); // 查看类型,如果是其他类型,比如视频则替换成 video/*,或 */*  
  4. Intent wrapperIntent = Intent.createChooser(intent, null);  
  5. startActivityForResult(wrapperIntent, requestCode);    


11 Intent.ACTION_VIEW 
String android.intent.action.VIEW 
用于显示用户的数据。 
比较通用,会根据用户的数据类型打开相应的Activity。 
比如 tel:13400010001打开拨号程序,http://www.g.cn则会打开浏览器等。 

Java代码  
  1. Uri uri = Uri.parse("http://www.google.com"); //浏览器   
  2. Uri uri =Uri.parse("tel:1232333"); //拨号程序   
  3. Uri uri=Uri.parse("geo:39.899533,116.036476"); //打开地图定位   
  4. Intent it = new Intent(Intent.ACTION_VIEW,uri);   
  5. startActivity(it);   

Java代码  
  1. //播放视频   
  2. Intent intent = new Intent(Intent.ACTION_VIEW);   
  3. Uri uri = Uri.parse("file:///sdcard/media.mp4");   
  4. intent.setDataAndType(uri, "video/*");   
  5. startActivity(intent);  

Java代码  
  1. //调用发送短信的程序   
  2. Intent it = new Intent(Intent.ACTION_VIEW);  
  3. it.putExtra("sms_body""信息内容...");   
  4. it.setType("vnd.android-dir/mms-sms");   
  5. startActivity(it);  


12 Intent.ACTION_SENDTO 
String: android.intent.action.SENDTO 
说明:发送短信息 

Java代码  
  1. //发送短信息   
  2. Uri uri = Uri.parse("smsto:13200100001");   
  3. Intent it = new Intent(Intent.ACTION_SENDTO, uri);   
  4. it.putExtra("sms_body""信息内容...");   
  5. startActivity(it);   

Java代码  
  1. //发送彩信,设备会提示选择合适的程序发送   
  2. Uri uri = Uri.parse("content://media/external/images/media/23");   
  3. //设备中的资源(图像或其他资源)   
  4. Intent intent = new Intent(Intent.ACTION_SEND);   
  5. intent.putExtra("sms_body""内容");   
  6. intent.putExtra(Intent.EXTRA_STREAM, uri);   
  7. intent.setType("image/png");   
  8. startActivity(it);  

Java代码  
  1. //Email Intent intent=new Intent(Intent.ACTION_SEND);   
  2. String[] tos={"android1@163.com"};   
  3. String[] ccs={"you@yahoo.com"};   
  4. intent.putExtra(Intent.EXTRA_EMAIL, tos);   
  5. intent.putExtra(Intent.EXTRA_CC, ccs);  
  6.  intent.putExtra(Intent.EXTRA_TEXT, "The email body text");   
  7. intent.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");   
  8. intent.setType("message/rfc822");   
  9. startActivity(Intent.createChooser(intent, "Choose Email Client"));  


13 Intent.ACTION_GET_CONTENT 

Java代码  
  1. //选择图片 requestCode 返回的标识  
  2. Intent intent = new Intent(Intent.ACTION_GET_CONTENT); //"android.intent.action.GET_CONTENT"  
  3. intent.setType(contentType); //查看类型 String IMAGE_UNSPECIFIED = "image/*";  
  4. Intent wrapperIntent = Intent.createChooser(intent, null);  
  5. ((Activity) context).startActivityForResult(wrapperIntent, requestCode);    

Java代码  
  1. //添加音频  
  2. Intent intent = new Intent(Intent.ACTION_GET_CONTENT);  
  3. intent.setType(contentType); //String VIDEO_UNSPECIFIED = "video/*";  
  4. Intent wrapperIntent = Intent.createChooser(intent, null);  
  5. ((Activity) context).startActivityForResult(wrapperIntent, requestCode);    

Java代码  
  1.  //拍摄视频   
  2. int durationLimit = getVideoCaptureDurationLimit(); //SystemProperties.getInt("ro.media.enc.lprof.duration", 60);  
  3. Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);  
  4. intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);  
  5. intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, sizeLimit);  
  6. intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, durationLimit);  
  7. startActivityForResult(intent, REQUEST_CODE_TAKE_VIDEO);  

Java代码  
  1. //视频  
  2. Intent intent = new Intent(Intent.ACTION_GET_CONTENT);  
  3. intent.setType(contentType); //String VIDEO_UNSPECIFIED = "video/*";  
  4. Intent wrapperIntent = Intent.createChooser(intent, null);  
  5. ((Activity) context).startActivityForResult(wrapperIntent, requestCode);    

Java代码  
  1. //录音  
  2. Intent intent = new Intent(Intent.ACTION_GET_CONTENT);  
  3. intent.setType(ContentType.AUDIO_AMR); //String AUDIO_AMR = "audio/amr";  
  4. intent.setClassName("com.android.soundrecorder",  
  5. "com.android.soundrecorder.SoundRecorder");  
  6. ((Activity) context).startActivityForResult(intent, requestCode);   

Java代码  
  1. //拍照 REQUEST_CODE_TAKE_PICTURE 为返回的标识  
  2. Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //"android.media.action.IMAGE_CAPTURE";  
  3. intent.putExtra(MediaStore.EXTRA_OUTPUT, Mms.ScrapSpace.CONTENT_URI); // output,Uri.parse("content://mms/scrapSpace");  
  4. startActivityForResult(intent, REQUEST_CODE_TAKE_PICTURE);    


转载完毕,以后有时间会加上自己的更新.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值