Translate this page

Fix Android Webview Camera Upload Error

How to Fix Android Webview Can’t Upload Image From Camera Directly

If you have implemented the code to support file upload in android Webview, but still unable to upload images, or if you can upload images from gallery but not from camera, then the issue is most likely error with permissions. If you are looking to make your android webview support file upload, see This page

I got in trouble with camera upload, my app simply wouldn’t be able to get a picture from camera, i mean the camera would not be shown in the file picker and i spent hours thinking my android webview upload code caught some error. I had the permissions set in manifest but this wasn’t enough, i needed ask user permissions and finally i figured it out.

Starting from marshmallow, android requires user permissions to access camera and external storage. Without these permissions, the Webview app can’t initiate a camera upload, so you have to make the user to grant permissions, So here is how to fix camera upload in android Webview

Code to fix Android camera image upload error

In your webview activity, add  this code below the OnCreate method.

if(!hasPermissions(this, PERMISSIONS)){
          ActivityCompat.requestPermissions(this, PERMISSIONS, PERMISSION_ALL);


Then add this code in the activity, that is it. Remember that you will have to declare permissions in your android manifest too

   String[] PERMISSIONS = {

   public static boolean hasPermissions(Context context, String... permissions) {
       if (context != null && permissions != null) {
           for (String permission : permissions) {
               if (ActivityCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {
                   return false;
       return true;


So this is it, this code is a clever one because it is easier, and if you want more permissions for your app, you can assign those in this code under String[]. Android will ask only required permissions in a sequence when user opens the activity.

Related Posts

Get Your Own Android Mobile App for Your Website Today

Are you looking to expand your online presence and reach more customers? In today’s digital age, having a mobile app is an essential tool to connect with…

Why making an app for your website can help your business to grow

In today’s digital age, it’s more important than ever to have a strong online presence. Whether you’re running a business, a blog, or a personal website, having…

person using macbook pro on person s lap

Fix android.content.Intent.migrateExtraStreamToClipData(android.content.Context)’ on a null object reference

Here is how to Fix Android Studio Error Attempt to invoke virtual method ‘boolean android.content.Intent.migrateExtraStreamToClipData(android.content.Context)’ on a null object reference This error is caused by a number…

Android Spinner onItemSelected Listener Example

Spinner is an android UI element; it provides a drop-down List where you can choose an item from the list. You will need a listener to catch…

person in gray shirt holding a small paper with texts

Get Current Month Name in Java Android

The code below can be used to get the name of current month, for example, January, February, March etc. Just call this method and it will return…

The future of android developers is not good

Are you an android developer or looking to be an android developer? You should read this Myself is zid, I’m an android developer and been in this…

This Post Has One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *