この関数をコードで使用するだけです...
int ACTION_REQUEST_GALLERY = 1 // YOU CAN PUT ANY INTEGER VALUE AS A REQUEST_CODE
private void pickFromGallery() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
Intent chooser = Intent.createChooser(intent, "Choose a Picture");
startActivityForResult(chooser, ACTION_REQUEST_GALLERY);
}
これがお役に立てば幸いです。
編集済み
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
switch (requestCode) {
case ACTION_REQUEST_GALLERY:
// user chose an image from the gallery
Uri uri = data.getData();
YOUR_IMAGE_VIEW.setImageURI(uri);
break;
}
}
}