Upload camera photo and filechooser from webview INPUT field

后端 未结 3 1730
灰色年华
灰色年华 2020-12-28 11:13

My app is webbased and I need to upload pictures from an INPUT field camp. I\'ve two situations and as i don\'t know another way to do it depending the page I\'m choosing on

3条回答
  •  旧巷少年郎
    2020-12-28 11:29

    Solved. Inside my question, there's the functional code in case anyone needs it.

    Here's the solution of the issues:

    1. Couldn't open camera/filechooser if I previously opened and cancelled:

      //inside onActivityResult
      if (resultCode != RESULT_OK) {
           mUploadMessage.onReceiveValue(null);
           return;
      }
      
    2. Get the "content://media/external/images/xxx" uri format, to upload the uri via "mUploadMessage.onReceiveValue(selectedImage);", avoiding a nullpointerexception

      //inside OnActivityResult
      getContentResolver().notifyChange(mCapturedImageURI, null);
      ContentResolver cr = getContentResolver();
      Uri uriContent = Uri.parse(android.provider.MediaStore.Images.Media.insertImage(getContentResolver(), photo.getAbsolutePath(), null, null));
      

提交回复
热议问题