Android Intent.createChooser 应用选择器
来源:互联网 发布:凤凰新闻软件下载 编辑:程序博客网 时间:2024/06/06 17:47
在常见的Activity Action Intent常量中,ACTION_PICK android.intent.action.PICK 是“选择数据”的意思,来简单的分享一下我知道的Intent.ACTION_PICK的一些用法:
(一)、调用图库,获取所有本地图片:
Intent imageIntent = new Intent(Intent.ACTION_GET_CONTENT);
imageIntent.setType(“image/*”);
startActivityForResult(imageIntent, PICK_CODE); //PICK_CODE是常量
(二)、调用本地联系人:
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
startActivityForResult(intent, PICK_CONTACT);
(三)、调用音乐,获取所有本地音乐文件:
Intent audioIntent = new Intent(Intent.ACTION_GET_CONTENT);
audioIntent.setType(“audio/*”);
startActivityForResult(audioIntent, PICK_AUDIO);
(四)、调用视频,获取所有本地视频文件:
Intent videoIntent = new Intent(Intent.ACTION_GET_CONTENT);
videoIntent.setType(“video/*”);
startActivityForResult(videoIntent, PICK_VIDEO);
例如:
public static void jumpToChooser(Activity activity) { if (activity == null) { return; } Intent intent = new Intent(Intent.ACTION_PICK); intent.setType("image/*"); PackageManager packageManager = activity.getPackageManager(); List<ResolveInfo> resInfo = packageManager.queryIntentActivities(intent, 0); if (resInfo != null && (!resInfo.isEmpty())) { List<Intent> targets = new ArrayList<>(); for (ResolveInfo info : resInfo) { Intent targeted = new Intent(Intent.ACTION_PICK); targeted.setType("image/*"); ActivityInfo activityInfo = info.activityInfo; String packageName = activityInfo.packageName; if (activityInfo != null && packageName != null) { if (packageName.contains(FILE_MANAGER) || packageName.contains(GALLERY_APP)) {//FILE_MANAGER,GALLERY_APP自定义包名 targeted.setPackage(packageName); targets.add(targeted); } } }// intent = Intent.createChooser(targets.remove(0), activity.getString(R.string.vrmake_setting_chooser_title)); intent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targets.toArray(new Parcelable[]{})); } activity.startActivityForResult(intent, PHOTO_REQUEST_GALLERY); }
- android Intent.createChooser 应用选择器 !!!
- android Intent.createChooser 应用选择器
- android Intent.createChooser 应用选择器
- Android Intent.createChooser 应用选择器
- Intent.createChooser 应用选择器
- Android Intent.createChooser()
- Android Intent.createChooser() .
- Android------Intent.createChooser
- Android 开发之:Intent.createChooser() 妙用
- Android 开发之:Intent.createChooser() 妙用
- 主题:Intent.createChooser() 妙用
- Intent.createChooser()的使用
- Intent中createChooser方法的使用
- 如何自定义Intent.createChooser的显示结果
- android createChooser 过滤多余app
- android Intent常见应用
- Android中Intent应用
- Android Intent应用详解
- Hibernate学习笔记--映射配置文件详解
- 死锁笔记
- SECCON CTF 2017 Powerful_Shell
- Struts-config.xml 配置 动态FormBean与action-mappings元素
- Oracle RMAN-备份集和镜像备份
- Android Intent.createChooser 应用选择器
- D3.js中Circle Packing详解
- Hibernate 第一个程序的问题Unknown entity(新手必看)
- Beyond Agile Programming
- scala数据结构之List列表
- C++单例模式
- 接口怎么实例化?
- python3.6 实现AES加密----pyCryptodome
- 斯坦福机器学习笔记01