Android——调用系统相册


一、调用系统相册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);


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM