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

Add Admob ads in recyclerview in android

How to add admob native ads to recyclerview in android java Adding admob native ads into android recyclerview isn’t easy like other admob ads. You will need…

Download WebView Flutter Source Code for Android and iOS

Easily create android and iOS WebView app for your websites, the much-awaited flutter WebView source code is here. Are you looking for a flutter WebView source code…

Fix uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:_flutter_android]

This error can be fixed by modifying build.gradle file in the flutter In android studio: go to android>app>build.gradle and modify it as follows:

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…

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…

This Post Has One Comment

Leave a Reply

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