Android Question Webview content choose to start camera and take photo as file selected

hung

Active Member
Licensed User
Longtime User
I have file upload code in server. The html code via mobile browser allows me use a camera to take photo then upload the photo to server, besides I could select other images files in phone.

However, when I use webview to load this html code, when clicking [Choose a File] in the html, I could only select image files. How could I enable camera auto started as [Choose a File]?

My code is similar as below. The html in Webview will trigger to run the code below.

B4X:
    cChooser.Initialize("CC")
    cChooser.Show("*/*", "Choose File")
    Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)
...
#if Java
import android.webkit.*;
import android.webkit.WebChromeClient.*;
import android.net.*;
public static void SendResult(Uri uri, ValueCallback<Uri[]> filePathCallback) {
    if (uri != null)
        filePathCallback.onReceiveValue(new Uri[] {uri});
    else
        filePathCallback.onReceiveValue(null);
        
}
public static class MyChromeClient extends WebChromeClient {
@Override
 public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback,
            FileChooserParams fileChooserParams) {
        processBA.raiseEventFromUI(this, "showfile_chooser", filePathCallback, fileChooserParams);
        return true;
    }
    }
#End If
 
Top