how to display image from my Computer on android emulator? - android

i wanna display image saved on the D://foldername//foldername//filename from my computer on the android emulator using eclipse and also how to display it from a server?
as i am accessing the data from the server and also the images are saved on the server

Unless you're running a web server which provides public access to the image, I don't think you can display an image from your computer using a path like that. You either need to include the image in the assets or res/drawable folders within the app, or have the image accessible through a web server which you can load from within the app using the method described in this question.

Related

Displaying images from dataDirectory in ionic2

I'm working on an app, using ionic2.
I'm storing a set of images that I downloaded from the server in the dataDirectory to save mobile traffic when the app is used without wi-fi.
Now, I would like to display them inside my template.
Is there a recommended way how the image should best be inserted?
I tried giving the ion-img or img-tag
the complete path (file.dataDirectory + “myImg.jpg” -> "file:///data/user/0/io.ionic.starter/files/myImg.jpg”
(stored in my imgPath variable, the path is written after the platform.ready event), but only a broken image symbol is shown. When accessing images from my assets folder I do not encounter any problems, but how can I access the dataDirectory’s images?
<img width=“200” height=“200” [src]=“imgPath” *ngIf=“imgPath”>
Or do I have to read each image from the dataDirectory and store them in a local variable as a base64 string?
There are many reason for showing broken image in IONIC.
If you are using live reload then sometime images are shown as broken image. You can run directly to see if it resolves your issue.
If you want to use base64 image, either you can save it SQLite or in local variable which may resolve your issue.

Loading an image from local server using the emulator within a program

I wrote a code that it can load an image from local host within an ImaheView in my application. My code is correct. because when I test my program within my device and using the PHPRunner application, it can load the image from the PHPRunner application and I can see the image in my program.
Now, I want to load the image in my program using the emulator. I have wamp server in my windows and so I saved my image in www/in/image.jpg folder.Also I changed the url address in my code as follows:
10.0.2.2:80/in/image.jpg
But when I run my program in emulator, it can not load the image from wamp server. Of course, when I open the browser through the emulator and I type the same code above: 10.0.2.2:80/in/image.jpg , I can see the image in the emulator through the browser.
But the problem is that I want to load the image when I run my application in emulator. Is there a way?
You should think of using A free file hosting service like somee. It's free and you can find tutorials on how to use it extensively. On that note, Android Emulators may listen to any Port, but I know for a fact that they would listen to :7541 so something like
10.0.2.2:7541
If that doesn't work or you are using a GenyMotion Emulator, you could try hosting the image on a file hosting site like I said or look at your ISP Provider IPv4 address Default Gateway if it is different

Gallery of pictures from distant site - Android

I need to add gallery to my android app. I used gallery in standard way, when pictures are in my folder, but now I need to show pictures when I have just pictures URLs(pictures are on some distant server). How can I achieve that ?
Is the server yours?
You might need to make an API to get the images from the server served to you.

Load images or whole site from local "assets" folder using webview

The question I have is simple but hard to put in words, I'll give it a try anyways.
I am trying to load a web page in webview. However, the load time is a little bit too high.
Is there any way I can put the images in the assets folder and load them from there instead?
If not, is there a way I can load the whole site from the assets folder, providing that my PHP files can still communicate with my internet database?
I have already read most tutorials, but those are pretty vague when it comes to concrete help.
try this... WebView with custom HTML and local images
There is no way to store your php files on the device itself. They need a server to execute them and sent the result to the device if the are on the device you would just show the php code to your webview and that would certainly not work.
The Webview should be able to cache some of the images itself. But it seems that there is no way to access images from the sd card or the internal storage from your webview.
Maybe it is possible to store some of your data through html5 local storage apis but I don't have any expertise on that.
Sure ! you can do it. Just install AndroPhp it is a localServer for Android.
Locate you project than on your device under the www/ folder. If you have a DB also just import your .sql trough phpmyadmin.
on Android side call you project 127.0.0.1:8080/yourProject
Thats All!

how to view all images in android's built- in gallery from a php page

I am developing an application to display all the images in android's built-in gallery in to a php page. I posted the uri (content://media/extrenal/images/media) of the gallery images to the php page. I was not able to recreate images by using webView's function loadUrl().
Should I need to upload the whole gallery to another directory and display the images?
Or passing the bitmap itself will do?
Please suggest me an idea to solve the problem.
I think you should make an ashynchronous connection of your application with an php application on the server, which will tell the android app to upload the requested image, and when the java app receives the upload command, make the app upload the picture to the server, and make the server php app display the image uploaded. I know this is a bit complicated, but this is the only thing that is comparatively easier than doing socket transports and other things. Good luck :)

Categories

Resources