Context:
My application sometimes displays "Tables", which are html files containing texts and images:
<p>image description </p>
<p><img src="/api/medias/get/videos/56afad6447eba61c8099544b?thumbnail=true&company=4f86d0a9d655ab9794f5d1d2&fullSizedCover=true"
alt=""
data-id="56afad6447eba61c8099544b"
data-type="video" data-width="640" data-height="1136" /></p>
Then i use body.loadDataWithBaseURL(<my api url>, body, "text/html; charset=UTF-8", null, null);
I do not think this is relevant, but I will say this just in case, I have a template body containing css and javascript. The js script detects images by clicking and passing the "data identifier" to the android method (via JavascriptInterface). In this case, he opens the video player and plays it.
Problem:
My application allows the user to download these sheets for the latest standalone vizualisation. So I upload html and then upload the images to my local private directory ( Context.getFileDir()) and change the src html to set the thumbnail sources to the uploaded images:
<p>video</p>
<p><img src="69c623955ecb5bd414f908cd383f3809.jpg"
alt=""
data-id="56afad6447eba61c8099544b"
data-type="video" data-width="640" data-height="360" /></p>
My question is: what do I set as the base url for my web view for me to get the expected behavior (i.e. display uploaded images).
I tried Context.getFileDir().getAbsolutePath(), content://com.android.htmlfileproviderand some others.
Should I do otherwise?
Many thanks,
This works well:
Picasso.with(iv.getContext()).load(new File(getContext().getFilesDir() + "/" + "69c623955ecb5bd414f908cd383f3809.jpg")).into(iv);
html:
<p>video</p>
<p><img src="69c623955ecb5bd414f908cd383f3809.jpg" alt="" data-id="56afad6447eba61c8099544b" data-type="video" data-width="640" data-height="360" /></p>
my base url: baseUrl = Uri.fromFile(getContext().getFilesDir()).toString();
And finally:
webview.loadDataWithBaseURL(baseUrl, body, "text/html; charset=UTF-8", null, null);