how to display .jpg image in android? - android

I am using .net web services and I am having list of folders and files. I am successful in retrieving list of files(.jpg Image, .pdf, .TIF) but can anybody let me know how we can open .jpg, .pdf, .tif or other files format which I am getting from web services. Is there any specific code to open particular format or we can use path (/) to open that particular file?
Thanks.

if you need to download and display an image, check my answer on this post, that is probably what you are looking for. Common extensions for displaying images in Android are .png and .jpeg, you will not be able to show a .pdf file using an ImageView. You can also use the method mentioned in my answer inside an AsyncTask to perform the download in background and then update your UI thread

Related

add file to queue download multi file android

Currently I want to make a list like pictures and images on the server when I click on it, it will download the images to the memory device. If the image is downloaded, it will not download again and the image that is not there will be downloaded. Then I want to ask for a solution from everyone, how should I handle the download to be clean and good for performance. Or do you have an example for me to refer to? Thank you!
There are some ways to find out if your image already exists in your phone storage but the best way to find it out is by image name, compare image names before downloading.

Android display files from URL GET

I'm working on the Android version of an app I did for iOS. I have some files (could be PDF, DOC, PNG, etc) in cloud storage and I retrieve them using an ASPX handler (like http://www.myserver.com/GetFile?name=test.png).
The goal is to DISPLAY ONLY, not download the files.
In iOS I used a UIWebView and it would download and preview the file as long as the OS could handle that file type.
What is the best approach for Android? I've tried the following:
WebView and embedding in google docs (http://docs.google.com/gview?embedded=true&url=) - DOES NOT WORK FOR PNG
Launching a new Activity using myIntent.setDataAndType(myFileURI, myFileMIME); where myFileMIME = MimeTypeMap.getSingleton().getMimeTypeFromExtension(myFileTypeExtension). For PNGS I get "No activity for type image/png"
I think you can try DownloadManager for this.
The second option is a better way for Android, after fetching the file from cloud.
Use MimeType as "image/*", which usually works for all images and opens in default gallery.
So what I've ended up doing is classifying the MIME type as shown above. If the type is "image/*" then I display the image directly in a WebView.
If the type is "application/*" then I embed it in google docs using the 1st method, and display it in the WebView.
Still looking for a better solution.

How to get list of *.jpg files on server?

I'm trying to find simplest solution to make app where I can download all the images from the specifed, hardcoded directory.
So far, my idea is to get list of all .jpg images (since it will be the only image format in this directory) and put it in places on ViewPager so each image will be on seperate page.
Anyone has nice snippet or friendly library to use to make it happen?
You can create a txt file on the server in which the URLs of all images will be kept; then program your app to download this file first; then use input stream to read the URLs from the file and create a loop to download all urls until they finish, by checking if the input is null.
On server side either add the urls manually to the file or write a JavaScript to automatically write the URLs when uploading the image.

How to load a .pdf or a .doc file in android

I want to show a pdf (preferably) or a word document in my app; like a privacy notice screen. Many applications have it, so it should be possible. i tried loading a simple text file as a start but doesn't provide formatting, fonts or trade mark symbols. I've gone through a few posts but I couldn't apply it to my app. Could anyone tell me how is it done? Could I store the file somewhere in res folder and provide a path to open it through my code? I looked into the following link but I'm not sure if that's the right approach in my case android: open a pdf from my app using the built in pdf viewer.
Android does not support opening PDF and DOC files natively. You'd have to make your own implementation.
Like t0mm13b said, you should consider using HTML (+ CSS) instead and use a WebView.

Android: How to get file list from url

I want to list files from url. For example, there are some jpeg files inside http://www.example.com/jpegfile/ that i want to list these files on my android app.
I know how to list files inside the phone, but i dont know how to list from url.
thank!!!
Well, before you can list your files from URL, you need to download them. Check this link, it will help you properly download your images, then you'll have to just show them where you want.
Multithreading for Performance

Categories

Resources