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);
posted @ 2012-09-25 15:36  Binary-Stream  阅读(5860)  评论(2编辑  收藏  举报