以下のように画像選択画面を起動したとする。
Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setType("image/*"); startActivityForResult(intent, GALLERY_REQUEST_CODE);
以下のようにしてbitmapを取り出せる。
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), data.getData());
ちなみにbitmapをファイルに書き出すには以下のようにする。
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); bitmap.compress(format, 90, outputStream); FileOutputStream stream = new FileOutputStream(path); stream.write(outputStream.toByteArray()); stream.flush(); stream.close(); outputStream.close();