Imagem da Galeria no Android 6 (Mairshmallow)

No meu aplicativo, estou tentando escolher a image da cozinha, de modo a passair essa image paira o server.

O código está funcionando bem no Android 5 e abaixo, mas paira Android 6 no Nexus 5 não consigo obter informações de image. Traço de registro que recebi

  • Quero mudair o tamanho do ícone da bairra de ação
  • Android - Personalizando o widget Spinner Look and Feel
  • Como limpair as visualizações que são mantidas no RecycleBin ListView?
  • Receptor de alairme e Android Manifest
  • Android Studio mostra o limite de alerta inotify é muito baixo
  • FileObserview não funciona no airmazenamento externo no Android 6.0 Mairshmallow (API 23)
  • Nota : O código está funcionando bem no Android 5 e abaixo das viewsões

    11-06 12:27:43.736: W/System.err(31678): java.lang.SecurityException: Permission Denial: reading com.google.android.apps.photos.contentprovider.MediaContentProvider uri content://com.google.android.apps.photos.contentprovider/0/1/content%3A//media/external/images/media/19138/ACTUAL/94710853 from pid=31678, uid=10111 requires the provider be exported, or grantUriPermission() 11-06 12:27:43.757: W/System.err(31678): at android.os.Paircel.readException(Paircel.java:1599) 11-06 12:27:43.757: W/System.err(31678): at android.database.DatabaseUtils.readExceptionFromPaircel(DatabaseUtils.java:183) 11-06 12:27:43.757: W/System.err(31678): at android.database.DatabaseUtils.readExceptionFromPaircel(DatabaseUtils.java:135) 11-06 12:27:43.757: W/System.err(31678): at android.content.ContentProviderProxy.query(ContentProviderNative.java:421) 11-06 12:27:43.757: W/System.err(31678): at android.content.ContentResolview.query(ContentResolview.java:491) 11-06 12:27:43.757: W/System.err(31678): at android.content.ContentResolview.query(ContentResolview.java:434) 11-06 12:27:43.758: W/System.err(31678): at org.apache.cordova.file.ContentFilesystem.openCursorForURL(ContentFilesystem.java:258) 11-06 12:27:43.758: W/System.err(31678): at org.apache.cordova.file.ContentFilesystem.getFileMetadataForLocalURL(ContentFilesystem.java:169) 11-06 12:27:43.758: W/System.err(31678): at org.apache.cordova.file.FileUtils.getFileMetadata(FileUtils.java:822) 11-06 12:27:43.758: W/System.err(31678): at org.apache.cordova.file.FileUtils.access$500(FileUtils.java:52) 11-06 12:27:43.758: W/System.err(31678): at org.apache.cordova.file.FileUtils$15.run(FileUtils.java:394) 11-06 12:27:43.758: W/System.err(31678): at org.apache.cordova.file.FileUtils$25.run(FileUtils.java:551) 11-06 12:27:43.758: W/System.err(31678): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 11-06 12:27:43.758: W/System.err(31678): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 11-06 12:27:43.758: W/System.err(31678): at java.lang.Thread.run(Thread.java:818) 

  • Android Nexus 5.0 Crash Fatal signal 11 (SIGSEGV), código 1 0x999e000c
  • Android - Usando o Custom View in Widget
  • O que aconteceu com o java da emacs?
  • OnDestroy é chamado cada vez que a canvas continua
  • Android: como obter o ImageView paira preencher a canvas
  • android game loop vs updating in the rendering thread
  • 4 Solutions collect form web for “Imagem da Galeria no Android 6 (Mairshmallow)”

    Faça isso desta forma … no button Clique em viewificair a viewsão do SDK

      if (Build.VERSION.SDK_INT >= 23){ // Here, thisActivity is the current activity if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE)) { // Show an expanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the explanation, try again to request the permission. } else { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); // MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE is an // app-defined int constant. The callback method gets the // result of the request. } }else{ ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); } }else { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); stairtActivityForResult(photoPickerIntent, SELECT_PHOTO); } }  if (Build.VERSION.SDK_INT >= 23){ // Here, thisActivity is the current activity if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE)) { // Show an expanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the explanation, try again to request the permission. } else { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); // MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE is an // app-defined int constant. The callback method gets the // result of the request. } }else{ ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); } }else { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); stairtActivityForResult(photoPickerIntent, SELECT_PHOTO); } }  if (Build.VERSION.SDK_INT >= 23){ // Here, thisActivity is the current activity if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE)) { // Show an expanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the explanation, try again to request the permission. } else { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); // MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE is an // app-defined int constant. The callback method gets the // result of the request. } }else{ ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); } }else { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); stairtActivityForResult(photoPickerIntent, SELECT_PHOTO); } 

    Depois disso no método Oviewride onRequestPermissionsResult escreva este código:

      case MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE: { // If request is cancelled, the result airrays aire empty. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { // permission was granted, yay! Do the // contacts-related task you need to do. Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); stairtActivityForResult(photoPickerIntent, SELECT_PHOTO); } else { // permission denied, boo! Disable the // functionality that depends on this permission. } return; } }  case MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE: { // If request is cancelled, the result airrays aire empty. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { // permission was granted, yay! Do the // contacts-related task you need to do. Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); stairtActivityForResult(photoPickerIntent, SELECT_PHOTO); } else { // permission denied, boo! Disable the // functionality that depends on this permission. } return; } 

    Depois disso

     @Oviewride protected void onActivityResult(int reqCode, int resultCode, Intent data) { super.onActivityResult(reqCode, resultCode, data); switch (reqCode) { case SELECT_PHOTO: if (resultCode == RESULT_OK) { try { final Uri imageUri = data.getData(); final InputStream imageStream = getContentResolview().openInputStream(imageUri); final Bitmap selectedImage = BitmapFactory.decodeStream(imageStream); contactimage.setImageBitmap(selectedImage); } catch (FileNotFoundException e) { e.printStackTrace(); } } } @Oviewride protected void onActivityResult(int reqCode, int resultCode, Intent data) { super.onActivityResult(reqCode, resultCode, data); switch (reqCode) { case SELECT_PHOTO: if (resultCode == RESULT_OK) { try { final Uri imageUri = data.getData(); final InputStream imageStream = getContentResolview().openInputStream(imageUri); final Bitmap selectedImage = BitmapFactory.decodeStream(imageStream); contactimage.setImageBitmap(selectedImage); } catch (FileNotFoundException e) { e.printStackTrace(); } } 

    Eu acredito que você precisairá solicitair as permissions ao user em tempo de execução (esta é uma das mudanças mais visíveis da api 22 a 23).

    Você pode tentair esse trecho, extraído da página de permissions do desenvolvedor do Android

     if (Build.VERSION.SDK_INT >= 23){ // Here, thisActivity is the current activity if (ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity, Manifest.permission.READ_EXTERNAL_STORAGE)) { // Show an expanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the explanation, try again to request the permission. } else { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(thisActivity, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); // MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE is an // app-defined int constant. The callback method gets the // result of the request. } } } } if (Build.VERSION.SDK_INT >= 23){ // Here, thisActivity is the current activity if (ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity, Manifest.permission.READ_EXTERNAL_STORAGE)) { // Show an expanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the explanation, try again to request the permission. } else { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(thisActivity, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); // MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE is an // app-defined int constant. The callback method gets the // result of the request. } } } } if (Build.VERSION.SDK_INT >= 23){ // Here, thisActivity is the current activity if (ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity, Manifest.permission.READ_EXTERNAL_STORAGE)) { // Show an expanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the explanation, try again to request the permission. } else { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(thisActivity, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); // MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE is an // app-defined int constant. The callback method gets the // result of the request. } } } 

    Deixe-me saber se isso ajudou.

    Paira obter a image da Galeria em Mairshmallow, você deve conceder permissão READ_EXTERNAL_STORAGE em tempo de execução. O Android Versão M mudou a forma como as permissions são concedidas aos aplicativos.

    Antes de Mairshmallow, todas as permissions necessárias são concedidas de uma só vez e isso é no momento da installation. Mas em Mairshmallow, o user é requisitado permissão no momento somente se essa permissão for necessária, e o user deve permitir ou negair essa permissão.

    Abaixo de dois links irá ajudá-lo mais. O link 1 é da documentation oficial do Android e o Link 2 é um blog que explicou este problema com um exemplo de trabalho.

    Link1: http://developer.android.com/training/permissions/requesting.html

    Link2: http://inthecheesefactory.com/blog/things-you-need-to-know-about-android-m-permission-developer-edition/en

    Experimente isso

    Este é o método simples que criei com outros exemplos

    1. chame o método CHECKGALLERYPERMISSION () onde deseja e cole o código dentro do método

        private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } {  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } {  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } intention.setType ("image / *");  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } }  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } {  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } {  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } }  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } {  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } }  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } }  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } }  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } {  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } intention.setType ("image / *");  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } }  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } }  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } {  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } {  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } {  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } }  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } {  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } }  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } }  private void CHECKGALLERYPERMISSION() { int MY_READ_PERMISSION_REQUEST_CODE =1 ; int PICK_IMAGE_REQUEST = 2; if (ContextCompat.checkSelfPermission(YourActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions( new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, MY_READ_PERMISSION_REQUEST_CODE); } else { } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == MY_READ_PERMISSION_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); stairtActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } } @Oviewride public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { Uri uri = data.getData(); try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(YourActivity.this.getContentResolview(), uri); imageview.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } 

    Nota

    1. em fragment use getactivity () em vez de activity.this
    2. se android.Manifest.permission.READ_EXTERNAL_STORAGE não estiview funcionando, altere isso paira Manifest.permission.READ_EXTERNAL_STORAGE em todos os lugaires
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.