I used default camera of device for capture photo in my app. When I used android 10 and below version everything is working fine. but when I used camera in android 11 then not working in app. Can you help me to solve this problem.
            Asked
            
        
        
            Active
            
        
            Viewed 1.3k times
        
    4 Answers
9
            
            
        Since API level 30, there have been changes in the package visibility. https://developer.android.com/about/versions/11/privacy/package-visibility
For your package manager to work properly, you need to declare <queries> in your AndroidManifest.xml:
Code:
<manifest package="your.package.name">
<queries>
    <intent>
        <action android:name="android.media.action.IMAGE_CAPTURE" />
    </intent>
</queries>
</manifest>
This works only for the default camera apps. If your app is using some 3rd party camera, you can find some info here.
        zhangxaochen
        
- 32,744
 - 15
 - 77
 - 108
 
- 
                    1Above code is not working in android 11.can you please help me about this issue. – Sahil Mar 02 '21 at 01:53
 - 
                    hi @Sahil ,you can refer this [link](https://github.com/ArthurHub/Android-Image-Cropper/issues/788),It's very detailed.Hope this could help you with your issue – zhangxaochen Mar 02 '21 at 01:56
 
1
            
            
        You need to change
File sd_directory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
to
File sd_directory = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
        Bhavesh Chand
        
- 495
 - 6
 - 7
 
1
            
            
        Add this to your manifest outside the application tag, I hope it will resolve your issue
<queries>
        <intent>
            <action android:name="android.media.action.IMAGE_CAPTURE" />
        </intent>
        <intent>
            <action android:name="android.intent.action.PICK" />
            <data android:mimeType="vnd.android.cursor.dir/image" />
        </intent>
</queries>
        pavan patil
        
- 13
 - 6
 
1
            
            
        Android 11 has Storage update. So When using SDK >= 29 must set URI instead of File path.
URI uri = null;   // set this uri in camera Intent
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
        {
           uri =  getApplicationContext().getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new ContentValues());
        }
        else
        {
            uri =   getApplicationContext().getContentResolver().insert(MediaStore.Images.Media.INTERNAL_CONTENT_URI, new ContentValues());
        }
    }
        Roshan kumar
        
- 21
 - 2