I have a html file (contains some text and one image) stored # /sdcard/test folder.
And image is also stored under same folder. I'am able to see the image on html file if i open html file programmatically (using a WebView).
((WebView)findViewById(R.id.webView)).loadUrl("file:///mnt/sdcard/test/report_external.html");
It works. But when i go to that folder and open that html file (using default web browser of android), image file is not getting displayed. It is showing everything except image. What is the problem with default android browser to view the html file? Are there any differences between opening the file using defalut browser & WebView?
Here is my image tag in html
<img src = "file:///mnt/sdcard/test/image.png"></img>
How could i see the image on html if it opened with default browser also?
I think there's something wrong with your img-path. Try to set src="image.png", it should work when both files are in the same directory. Let me know if it works.
Change the name of the image to something else and try. might work.
try file:///sdcard/test/report_external.html
instead of file:///mnt/sdcard/test/report_external.html
That's remove /mnt in your path, does it work now?
Related
Is there a simple way to open an image in new Activity on clicking it inside the webview?
Or It would be great if I can get the full url of the image on clicking it inside the webview.
Not possible, because how should you get the image url ?
it is difficult to get return values from webview events outside the context of webview.
if you have the direct URL of image then you can easily rendered it on UI but without direct URL you can't render an image.
Create an HTML file
<html>
<img src="abc.jpeg" width="100px" >
</html>
put it in an assests folder of your android application and load the html in your webview
webview.loadUrl("file:///android_asset/abc.html");
You can store the image in the assets folder along with the html
page, and specify the image name as the value of src in img tag
in html code,
or you can give the public URL of the image and the image will be
renderd on its own
I need to hide image(not folder) in both file browser and gallery without changing the file location. I tried prefixing the file name with . it hides the image in the file browser but still showing in gallery. Is there any way to hide image from gallery?
Create a .nomedia file in the same (or parent) directory of the image. This will hide all media in the current directory and subdirectories. (The media scanner will not scan this directory).
I need to hide image(not folder) in both file browser and gallery
without changing the file location.
My thought over this problem is
You can change the extension(make file without any extension) so media scanner will not able to detect it.
e.g file name us test.png rename it to only test
I have image paths stored in my websql database.
Paths like:
/storage/sdcard/DCIM/Camera/IMG_20150212_21212.jpg
I want to display these images within my image element:
<img src="path" />
But the image is not displayed. I know that path is wrong, so I tried these variations:
file:///storage/sdcard/DCIM/Camera/IMG_20150212_21212.jpg
cdvfile://storage/sdcard/DCIM/Camera/IMG_20150212_21212.jpg
file://localhost/storage/sdcard/DCIM/Camera/IMG_20150212_21212.jpg
cdvfile://localhost/storage/sdcard/DCIM/Camera/IMG_20150212_21212.jpg
What is the correct path and how can I display the image?
This works for me on android:
"file:///mnt/sdcard/DCIM/Camera/IMG_20150212_21212.jpg"
I have an Android WebView loaded with a html file(actually stored in some folder under sdcard) that is having one/two/three image(s). Is it possible to drag-drop any one of those images?
If its possible, below are my doubts
When i drag an image from (x1,y1) place and drop it in another (x2,y2)place, How can i change the original source file code as the image place is changed ?
When i open the same html file in next time (using default html viewer or my app), i should see the image in (x2, y2) place. Isn't it possible ?
I tried this drag ImageView inside a WebView. But it is just adding an imageview to webview. (So, when i run the same app next time, i don't see the image in the place where i dropped it in first run.) But i need to drag an image presented in source html file. So After every drag-drop, Do i need to render the webview content and create a new html file to see the image in dropped location?
Is it possible to read the android-webview content? (like we read the web page content in java).
Can anyone clear my doubts and suggest me a better way if iam going/thinking wrong?
I don't think it possible (without using some not trivial tricks) to implement the drag and drop as you wish. for the other point's you raised - if the file is on your sd - why not just parse the html file and get the pictures positions and source link and use it to implement the drag and drop on your own? after all- the html file is an xml file which contains attributes which defines positions/links/images/text
I designed some radio buttons with images using css, because I want to make the radio button look bigger.
Now, when I load it in browsers it works fine, same in mobile browsers. But when I try to load it in webview the radio button is not visible. Is there anyway to enable css?
You don't need to enable css. You just link to it from you html file like you normally would
Put the html, css and image resource files in the assets folder of your project and load the html using "file:///android_asset/yourwebpage.html" as a Url.
if your css file is separate then you need to provide complete relative path in html page you include the html page like file:/// something like that.
mobile brower can take relative path by itself like say your accessing from wampserver but if you are putting all in webview and loading then it dont take relative path by itself. By the way where you are putting all this files in assests or sdcard ?