问题
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