我想为图像预览创建一个简单的按钮,此代码可以正常工作,但是当我使用Google相册打开图像(因为这是我在小米手机上获得的唯一图库应用程序)时,无法加载图片,只是黑屏,中间的加载圆圈试图打开图像,但从不这样做。 任何想法我该如何解决?
private static final int EXPLICIT_ACTIVITY_REQUEST_CODE = 0;
private static final int PICK_IMAGE = 1;
public void onStart_Picture(View view){
Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT);
getIntent.setType("image/*");
Intent pickIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
pickIntent.setType("image/*");
Intent chooserIntent = Intent.createChooser(getIntent, "Select Image");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{pickIntent});
startActivityForResult(chooserIntent, PICK_IMAGE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode,resultCode,data);
if(requestCode == PICK_IMAGE)
{
if(resultCode == RESULT_OK)
{
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri imageUri = data.getData();
intent.setDataAndType(imageUri,"image/*");
startActivity(intent);
}
}
}