Android: Sending image URI from webview website to app

六眼飞鱼酱① 提交于 2020-01-06 02:14:07

问题


I'm trying to send an image URI from a Website canvas to application with Javascript. In the Website I'm using the following function that relies on the html2canvas plugin:

$("div.imagecapture").click(function()
{
    html2canvas(document.getElementById('paper_trolley_center'), 
    {
                onrendered: function(canvas) 
        {
            var strDataURI = canvas.toDataURL("image/jpeg");
            console.log('La imagen: '+strDataURI);
            jsNativeInterface.metodoDemo1(strDataURI);
                }
             });
});

The console.log outputs the URI, but the application is receiving a null value:

    public void metodoDemo1(Uri imageUri) 
    {  
             Log.d(TAG, "IMAGEURI: "+imageUri);
             senddatatodevice(imageUri);
    }

The data transmission between the app and the webview website works fine as I can receive a string (changing the casting of metodoDemo1) and do the log correctly... What can it be?


回答1:


Try passing it as String. Uri in JavaScript is something else as in Android.

public void metodoDemo1(String imageUri)


来源:https://stackoverflow.com/questions/15808602/android-sending-image-uri-from-webview-website-to-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!