intent的使用小结--持续更新中

简介: intent的使用小结--持续更新中

1.进入联系人界面

Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(People.CONTENT_URI);
startActivity(intent);

2.查看某个联系人,当然这里是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);

3.选择一个图片

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);  
intent.addCategory(Intent.CATEGORY_OPENABLE);  
intent.setType("image/*");
startActivityForResult(intent, 0);

4.调用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);

5.搜索指定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)


相关文章
|
5天前
|
Java Android开发
Android开发--Intent-filter属性详解
Android开发--Intent-filter属性详解
11 0
|
Android开发
Intent的基本使用
显式Intent:通过组件名指定启动的目标组件,比如startActivity(new Intent(A.this,B.class));每次启动的组件只有一个 隐式Intent:不指定组件名,而指定Intent的Action,Data,或Category,当我们启动组件时,会去匹配AndroidManifest.xml相关组件的Intent-filter,逐一匹配出满足属性的组件,当不止一个满足时,会弹出一个让我们选择启动哪个的对话框
52 0
自定义ViewGroup的知识点总结-持续更新
自定义ViewGroup的知识点总结-持续更新
|
Java Android开发 数据格式
Android开发教程 - 使用Data Binding(三)在Activity中的使用
本系列目录 使用Data Binding(一)介绍 使用Data Binding(二)集成与配置 使用Data Binding(三)在Activity中的使用 使用Data Binding(四)在Fragment中的使用 ...
1077 0
|
Android开发
Android开发中的Intent和Activity
周末撸了几次代码, 舍不得扔, 立此为照!
7094 0
http://www.vxiaotou.com