首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

intent调用代码小结二

2012-09-17 
intent调用代码总结二?进入联系人界面?Intent intent new Intent()intent.setAction(Intent.ACTION_VIE

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

热点排行