Upload an Image from camera or gallery in WebView

前端 未结 5 1753
南笙
南笙 2020-11-27 14:36

WebView in this app opens a page with upload button.

\"Page

Below is th

5条回答
  •  有刺的猬
    2020-11-27 15:17

    I am sorry for my English.

    This is a solution.

    The first, you define file members like this.

    public File mTempFile;

    your's open file chooser is ok.

    onActivityResult method is so important.

    the camera app does not return URL, but ValueCallback must have URL.

    Get URI from mTempFile.

    this is work.

    I use to like this.

    if ( mTempFile.exists() ) {
    
        mUploadMessage.onReceiveValue(Uri.fromFile(mTempFile));
        mUploadMessage = null;
    
    } else {
    
        mUploadMessage.onReceiveValue(result);
        mUploadMessage = null;
    }
    

    If mTempFile is exist that was called camera, other case from gallery.

提交回复
热议问题