Home.java
public void updatePhoto(Bitmap bitmap) {
String bitmapStr = BitMapToString(bitmap);
Home.currentBmp = bitmap;
String parameter = "data:image/jpeg;base64," + bitmapStr;
webView1.loadUrl("javascript:var script = document.createElement('script');" +
"script.type='text/javascript';script.src='form.js';" +
"script.onload=" + "processImage('" + parameter + "');" +
//"script.onload=" + "processImage(':/;//');" +
"document.getElementsByTagName('head').item(0).appendChild(script);");
Log.v(parameter, "QWERTY");
Log.v("QWERTY", parameter);
}
form.js
function processImage(img) {
alert('process image end');
}
this function converts the Bitmap object into a base64 String, then executes an external javascript function (form.js -> processImage(var))
. However it doesn't execute processImage and gives an Uncaught SyntaxError: Unexpected token ILLEGAL
. However when i uncomment the
//"script.onload=" + "processImage(':/;//');" +
line and comment in
"script.onload=" + "processImage('" + parameter + "');" +
it seems that the function is working well. The possible value for parameter variable would be
data:image/jpeg;base64,iVBORw0KgoAAAANSHUEgAAA......
What I am asking is how am I gonna make the javaScript function work with the parameter? Thanks!