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.
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 would like to generate a PDF usgin data from my databse to a preset PDF template. The question will be, do you think or is it possible to send data or generate this pdf to a template using Android or do you think it is best to send the data to a server and have the server generate the PDF instead?
I know that Android can generate a PDF, but the bigger question will be can it insert data into a layout template and then generate it?
Is there any way to show Excel file in my application? Like if you want to show webpage you will use Webview. Or the only way is open another app by Intent?
Yes, after a fashion. You can use jexcelapi, a java library to read/write Excel files. I've used this in one of my apps to import and export data using spreadsheets. It was a classroom app, and all the data had to end up in spreadsheets for the school anyway.
You'll have to put the data into your app via TextView or WebView or some other method as you can't simply run excel on your Android device without an office file reader. Not all phones have those.
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.
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.