从图库

时间:2016-06-30 15:33:52

标签: android android-permissions android-gallery

当我的应用程序第一次运行并且我尝试从库中选择用户的图像时,系统会要求访问照片库的权限,当我允许权限并尝试选择图像时(从缩略图中选择)图像显示为完全空白(或者可能是完全黑色)一旦我重新启动应用程序这个问题自己解决了任何线索为什么会发生这种情况?

当我第一次尝试访问图库时(并允许权限) 这就是我的画廊的样子:

完全正常

enter image description here

当我从缩略图中选择任何图像时, 看到那里什么都没有(完全空白) enter image description here

如果我选择此(空白)图像:

enter image description here

但是一旦我重新启动应用程序 并从缩略图中选择任何图像,从现在开始工作正常 enter image description here

如果有人在此之前遇到类似情况,请告诉我

CODE:

userImageView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {


    if (Build.VERSION.SDK_INT >= 23){


        if (ContextCompat.checkSelfPermission(ProfileSetting.this,
                Manifest.permission.READ_EXTERNAL_STORAGE)
                != PackageManager.PERMISSION_GRANTED) {

            requestPermissions(new String[] {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE},
                    REQUEST_CODE_ASK_PERMISSIONS);

        }else {


            //Start Activity To Select Image From Gallery
            Intent gallery_Intent = new Intent(ProfileSetting.this, GalleryUtil.class);
            gallery_Intent.putExtra("Switch", 0);
            startActivityForResult(gallery_Intent, GALLERY_ACTIVITY_CODE);
        }


    }else {



        //Start Activity To Select Image From Gallery
        Intent gallery_Intent = new Intent(ProfileSetting.this, GalleryUtil.class);
        gallery_Intent.putExtra("Switch", 0);
        startActivityForResult(gallery_Intent, GALLERY_ACTIVITY_CODE);

    }


}
});

0 个答案:

没有答案
相关问题