Stai facendo male. Hai 2 modi per farlo, e dipende da cosa sta ricevendo quell'immagine.
Caso 1: si desidera restituire un array di byte. In questo caso, dovresti avere un Javascript che lo tratta e lo analizza in una stringa e assegnalo al campo src del tuo tag sul webView.
File imagefile = new File(otherPath);
FileInputStream fis = null;
try {
fis = new FileInputStream(imagefile);
finall = fis;
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Bitmap bi = BitmapFactory.decodeStream(fis);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
//PNG OR THE FORMAT YOU WANT
bi.compress(Bitmap.CompressFormat.PNG, 100, baos);
byte[] data = baos.toByteArray();
InputStream is = new ByteArrayInputStream(finaldata);
return new WebResourceResponse("text/html", "UTF-8", is);
Caso 2: si analizza tutto sulla attività e passare il codice completo HTML così nel WebView si avrà una proprietà innerHTML che verrà aggiornato con questi dati.
File imagefile = new File(otherPath);
FileInputStream fis = null;
try {
fis = new FileInputStream(imagefile);
finall = fis;
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Bitmap bi = BitmapFactory.decodeStream(fis);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
//PNG OR THE FORMAT YOU WANT
bi.compress(Bitmap.CompressFormat.PNG, 100, baos);
byte[] data = baos.toByteArray();
String image64 = Base64.encodeToString(data, Base64.DEFAULT);
String customHtml = "<html><body><h1>Hello, WebView</h1>" +
"<h2><img src=\"data:image/jpeg;base64," + image64 + "\" /></img></h2></body></html>";
InputStream is = new ByteArrayInputStream(finaldata);
return new WebResourceResponse("text/html", "UTF-8", is);
Nel caso in cui si desidera solo per caricare l'immagine che si può sempre fare un webView.loadData(String data, String mimeType, String encoding)
Speranza che aiuta, ho appena ricevuto il mio lavoro con questo