Android——调用系统相册

来源:互联网 发布:用友成都java招聘 编辑:程序博客网 时间:2024/05/16 09:51

一、调用系统相册App,浏览所用图片

        Intent intent = new Intent();        intent.setAction(Intent.ACTION_VIEW);        intent.setType("image/*");        startActivity(intent);

 

二、调用系统相册,并从中选择一张照片

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

 

三、调用系统相册查看单张(或特定)图片(此处系转载:http://java-android.blogbus.com/logs/151611473.html)

复制代码
    //下方是将ImageList集合中的图片路径转换为可供File识别的String数据,    String value = String.valueOf(mImagesList.get(pos).getPicturePath());    File file = new File(value);    //下方是是通过Intent调用系统的图片查看器的关键代码    Intent intent = new Intent();    intent.setAction(android.content.Intent.ACTION_VIEW);    intent.setDataAndType(Uri.fromFile(file), "image/*");    startActivity(intent);
复制代码
0 0
原创粉丝点击