本文實例講述了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); }
將上述代碼寫入onClick事件中即可!
希望本文所述對大家的Android程序設計有所幫助。
新聞熱點
疑難解答
圖片精選