intent调用代码总结二

 

进入联系人界面

 

Intent intent = new Intent();

intent.setAction(Intent.ACTION_VIEW);

intent.setData(People.CONTENT_URI);

startActivity(intent);

 

 查看某个联系人,当然这里是ACTION_VIEW,如果为选择并返回action改为ACTION_PICK,当然处理intent时返回需要用到startActivityforResult

 

 Uri personUri = ContentUris.withAppendedId(People.CONTENT_URI, ID);//最后的ID参数为联系人Provider中的数据库BaseID,即哪一行

 Intent intent = new Intent();

 intent.setAction(Intent.ACTION_VIEW);

 intent.setData(personUri);

startActivity(intent);

 

 选择一个图片

 

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);  

intent.addCategory(Intent.CATEGORY_OPENABLE);  

intent.setType("image/*");//此处->audio/*对应选择音频 video/*对应选择视频

startActivityForResult(intent, 0);

 

 调用Android设备的照相机,并设置拍照后存放位置

 

 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);  

intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Environment

.getExternalStorageDirectory().getAbsolutePath()+"/cwj", android123 + ".jpg"))); //存放位置为sdcard卡上cwj文件夹,文件名为android123.jpg格式

startActivityForResult(intent, 0);

 

 搜索指定package name在market上,比如搜索com.android123.cwj的写法如下

 

Uri uri = Uri.parse("market://search?q=pname:com.android123.cwj");   

Intent intent = new Intent(Intent.ACTION_VIEW, uri);   

startActivity(intent); 

 

本文转载自:http://www.android123.com.cn/androidkaifa/629.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值