What is the best format of saving a link to a web page?
I want it to get saved so that I could display the link (or a file that represent the link) in my app and could later display the actual page in the WebView.
I've tried creating an URL file but it seems there no predefined programs for opening this file format.
P.S. I need this format to be recognized by the default browser
In my opinion SharedPreference is the best way.
Couldn't find the appropriate format - solved the problem by saving the link to a txt file.
Related
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.
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
I'm trying to create an activity to show information about the monuments. What I thought is to create HTML files and then display them with a WebView. The problem is that I also need to export these contents on sdcard in some type of readable format (preferably pdf but I read some things and it seems very difficult and then I tried several solutions without success). How can I do this? Should I start from another type of format different from HTML?
Advise me a path to follow ... I do not know what else to try.
Thanks in advance. :)
Michele
There are multiple options. I would suggest go the PDF way.
If you have control over the contents, then the best way would be to create PDFs and you can then send a intent to open the PDF. If there are multiple PDF viewers available, then the intent will give an option for the user to select the viewer. If there is only one viewer available, the PDF will be opened in the viewer. If there are no available options, you can then send them to Google Play (Android Market) to download a PDF viewer and then view the PDF.
I have a url which directly downloads .pl file as xml on passing latitude and longitude within url. Now I have to first dowload it and then extract data from XML. However, i guess again and again downloading will not be a gud solution as it will make app slower. Hence, I was thinking is there a way where i can avoid downloading and make that xml directly open in browser and then parse it using SAX parser. Can I store it some variable or something similar and then can parse it?
Thanks
Astha
You need to download the data, which means retrieve the information from a distant server. What you could achieve is to try reading the file as you download it instead of downloading (ie saving in a temp file) then reading it.
It's the same idea as watching a streaming video (youtube ...) instead of downloading then watching a video.
I have no idea though on how to read directly a stream being downloaded.
So I want to store a string on my website and then have my app download it, so I could use it in a layout. How could I do that? I there a way I can take html files and have android read that text? or can I store a .txt and have android convert that to a string?
Thanks
If I understand you correctly, you could just put the string inside of a file that your web server will serve up for you (maybe omit the extension altogether). You can then download it from an android app using the file's url.
It seems like you might want to look into JSON, it will facilitate storing structured data instead of just a string.
Here is an example of downloading a url from an Android program.