0

I'm doing a webview application. I have a form on my site and an image upload process is required via the form. I select the camera via file_input, take the photo, but when I go back I see that the image is not saved in file input. Versions not working (I don't know all): Android 10, Android 7. Running versions: Android 9, Android 5. Im just back-end web developer, im not very good at mobile programming. Finally; The code below returns null.

takePictureIntent.resolveActivity(activity_ismi.this.getPackageManager()) // returns null

//For Android 5.0+
        @SuppressLint("QueryPermissionsNeeded")
        public boolean onShowFileChooser(
                WebView webView, ValueCallback<Uri[]> filePathCallback,
                WebChromeClient.FileChooserParams fileChooserParams){
            if(mUMA != null){
                mUMA.onReceiveValue(null);
            }
            mUMA = filePathCallback;
            Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            if(takePictureIntent.resolveActivity(customActivity.this.getPackageManager()) == null){
                File photoFile = null;
                try{
                    photoFile = createImageFile();
                    takePictureIntent.putExtra("PhotoPath", mCM);
                }catch(IOException ex){
                    Log.e(TAG, "failed to create image", ex);
                }
            }
            Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
            contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
            contentSelectionIntent.setType("*/*");
            Intent[] intentArray;
            if(takePictureIntent != null){
                intentArray = new Intent[]{takePictureIntent};
            }else{
                intentArray = new Intent[0];
            }

            Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
            chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
            chooserIntent.putExtra(Intent.EXTRA_TITLE, "Please select");
            chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
            startActivityForResult(chooserIntent, FCR);
            return true;
        }

I captured image from camera but input file this like:enter image description here

hami
  • 1
  • 1
  • where do you set the uris from camera result to `mUMA` , like (`mUma.onrecieveValue(your image uri))` – aryanknp Nov 19 '20 at 13:43
  • this: https://i.ibb.co/RY3Wg7f/samp.png – hami Nov 19 '20 at 14:08
  • can you help me? @aryanagarwal – hami Nov 20 '20 at 11:06
  • Yes I will help can you attach image as code , as it will be easy to copy the code then – aryanknp Nov 20 '20 at 12:15
  • I don't fully understand, but I'm waiting for your help. Since the codes do not fit the text of the comment, I wanted to show it as an image. I can write the codes below if you want. @aryanagarwal – hami Nov 20 '20 at 13:15
  • No you can edit the question and add your code , you are new thats why you arent aware of so features , if you are having trouble adding it no problem I will have a glance over it and will try to decipher the solution in some time when I am free – aryanknp Nov 20 '20 at 13:16
  • Okay, im waiting. Thanks. – hami Nov 20 '20 at 14:10
  • I am very sorry I am not able to give time because of some work , I suggest you to try this https://developer.android.com/training/camera/photobasics and also have a look at this https://stackoverflow.com/questions/13284903/upload-camera-photo-and-filechooser-from-webview-input-field – aryanknp Nov 21 '20 at 16:43
  • Hello, it doesn't matter. But I would be glad if you could help me fix the problem. I checked the link you posted, but it never worked. My code doesn't work on Android 6 and 10 versions. You can send ready code if you want. Thank you. @aryanagarwal – hami Nov 23 '20 at 07:58
  • @aryanagarwal I got a little closer to solving the problem and shared detailed information here. I will delete the current post soon. new post: https://stackoverflow.com/questions/64966034/webview-captured-image-save-not-working-some-versions-of-android – hami Nov 23 '20 at 09:50

0 Answers0