Vrittisolutions commented on issue #797:
URL: 
https://github.com/apache/cordova-plugin-camera/issues/797#issuecomment-2238513794

   I have used this olution and it's work for me
    private void requestGalleryPermission() {
           try {
               if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
                   // Android 13 and above
                   if (ContextCompat.checkSelfPermission(this, 
Manifest.permission.READ_MEDIA_IMAGES) != PackageManager.PERMISSION_GRANTED ||
                           ContextCompat.checkSelfPermission(this, 
Manifest.permission.READ_MEDIA_VIDEO) != PackageManager.PERMISSION_GRANTED ||
                           ContextCompat.checkSelfPermission(this, 
Manifest.permission.READ_MEDIA_AUDIO) != PackageManager.PERMISSION_GRANTED) {
   
                       ActivityCompat.requestPermissions(this,
                               new 
String[]{Manifest.permission.READ_MEDIA_IMAGES,
                                       Manifest.permission.READ_MEDIA_VIDEO,
                                       Manifest.permission.READ_MEDIA_AUDIO},
                               201);
                   } else {
                       startGalleryIntent();
                   }
               } else {
                   // Below Android 13
                   if (ContextCompat.checkSelfPermission(this, 
Manifest.permission.WRITE_EXTERNAL_STORAGE) != 
PackageManager.PERMISSION_GRANTED ||
                           ContextCompat.checkSelfPermission(this, 
Manifest.permission.READ_EXTERNAL_STORAGE) != 
PackageManager.PERMISSION_GRANTED) {
   
                       ActivityCompat.requestPermissions(this,
                               new 
String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,
                                       
Manifest.permission.READ_EXTERNAL_STORAGE},
                               201);
                   } else {
                       startGalleryIntent();
                   }
               }
           } catch (Exception e) {
               Log.e("Exception", "in permission----->" + e);
           }
       }
   
       private void startGalleryIntent() {
           Intent intent = new Intent(Intent.ACTION_PICK,
                   MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
           startActivityForResult(intent, RESULT_LOAD_IMG);
       }


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to