Android Question Send selected file to WebView Page..

nicieri

Active Member
Licensed User
Longtime User
Hi!,
For a long time I have used this code without problems to pass a selected image when it is requested from a website that I load in a WebView, the problem is that since version 34, it no longer does this, and the problem is that it does not give me any error, the file does exist, but I no longer receive it on the web side.

Any idea? What could have changed?


B4X:
        ' Verificar los bytes antes de enviar
        Dim bytes() As Byte = File.ReadBytes(Starter.Provider.SharedFolder, "TempFile.jpg")
        Log("Número de bytes leídos: " & bytes.Length)
        
        ' Enviar el resultado
        spp.fme = Me
        Dim jo As JavaObject = spp.fme
        
        Log(Starter.Provider.GetFileUri("TempFile.jpg"))
        
        jo.RunMethod("SendResult", Array(Starter.Provider.GetFileUri("TempFile.jpg"), spp.f))
        Log("Resultado enviado")

    Catch
        Log("Error: " & LastException.Message)
    End Try
End Sub



#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 void GeolocationPermissionResult(String origin, GeolocationPermissions.Callback callback, boolean allow) {
    callback.invoke(origin, allow, allow);
}
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;
    }
    @Override
    public void onGeolocationPermissionsShowPrompt (String origin,
                GeolocationPermissions.Callback callback) {
        BA.Log("onGeolocationPermissionsShowPrompt: " + origin);
        processBA.raiseEventFromUI(this, "request_locationpermission", origin, callback);
    }
    public void onPermissionRequest(PermissionRequest request) {
        request.grant(request.getResources());
    }
    }
#End If
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…