我尝试使用以下
将图像加载到ImageButtonif (resultCode == RESULT_OK) {
Uri imageUri = my_intent.getData();
try {
instream = getContentResolver().openInputStream(imageUri);
Bitmap image = BitmapFactory.decodeStream(instream);
imgLogo.setImageBitmap(image);
} catch (FileNotFoundException e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(), "Something went bad", Toast.LENGTH_LONG).show();
}
}
但是我在ActivityResult方法中得到了一个空的内部原因?
答案 0 :(得分:0)
你能试试这个方法吗
if (resultCode == RESULT_OK) {
Uri imageUri = my_intent.getData();
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), imageUri);
}
希望它有所帮助! :)
答案 1 :(得分:0)
试试这个
if (resultCode == RESULT_OK) {
Uri imageUri = my_intent.getData();
imgLogo.setImageURI(imageUri);
}