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