安卓---读取照片---拍照 - 大白社区

发帖时间:
2019-10-03 10:50:13
移动开发 65

摘要:实例讲述android打开本地图像的方法。分享给大家供大家参考。具体如下: 方法一,调用手机安装的图像...intent.setType(\"image/*\"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(inte...

实例讲述android打开本地图像的方法。分享给大家供大家参考。具体如下:

方法一,调用手机安装的图像浏览工具浏览:

Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, 1);

 方法二,调用手机自身图像浏览工具浏览:

Intent intent = new Intent(
  Intent.ACTION_PICK,
  android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
  intent.setType("image/*");
  PackageManager manager = getPackageManager();
  List<ResolveInfo> apps = manager.queryIntentActivities(intent,
   0);
  if (apps.size() > 0) {
   startActivityForResult(intent, 0x2001);
  }

 

 

 

 

 

 

   

转载于:https://www.cnblogs.com/rainday1/p/5761744.html

移动开发

本文在知识共享 署名-相同方式共享协议之条款下提供。

阿不推荐

热门话题