apache cordova show local img file - android

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"

Related

Android how to load Image file with different extension using Picasso

This is a different situation. I want to load a image file which has stored with different extension like 'photo.xyz' instead of 'photo.jpg or photo.png' using Picasso. to avoid image from gallery i am storing image like this. Please help me is there any option to show like this.
Neither Picasso nor Android (which does the actual image decoding) cares what the file name is. It can be anything. The type of the image is always determined from the first few bytes of the actual image data.
As a small workaround you can programmatically put .nomedia file into your app folder to prevent images to be cached by mediaserver and displayed in a Gallery app.

How to set imageview.toImage() as html image src in webview?

any idea to set imageview.toImage() as img src in html of a webview.
let suppose I have an imageview (having some image in it).okay imageview.toimage() is treated as an image object in titanium. now what i need is i want to set
webview.html='<html><img src="here i want to put obove imageview.toimage()"></html>';
I tried many way anyone have experience of it please guide me.
regards:ali
save it to a file and assigne the file's url path OR base64Encode the image and provide that as the value for the src parameter
you might try to convert the image into a base64 blob text and use it as css background image data :
background-image:url('data:image/png;base64,'+Ti.Utils.base64encode(imageview.toImage()).getText()+'\');

Adding images to android project - eclipse

i am trying to add an image in my android app. I am using html. I have my photos in the res/drawable folder. I use the code img src= but i just get a question mark over the image. What am i doing wrong?
Try using:
<img src="file:///android_res/drawable/image.png" />
You do not need to put the qualifier for the drawable in the SRC attribute.

Missing image on html file in android default web browser

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?

android : how to specify the path of image in source code

I want to display some text and image in webview. FOr this i am using a template html string.
Within this template i want to replace the {image} with the path for an image in drawable folder
i tried
str = str.replace("{image}","res/drawable-hdpi/about.png" )
but the image is not coming.
Is this the right way to give path.
Or what is the right solution
Thanks a lot for your time and help

Categories

Resources