I have created a web portal on drupal from where users will upload files on the server.
Lets take for example after uploading files :
location of the file is :
website.com/userfiles/college/year/subject/file1.pdf
now I want to display this hierarchy in android App.
I want to display a List View / Recycler View which automatically gets the names of files in subject folder and display it dynamically.
(If i add another file in the same folder on web, same gets automatically reflected in the app, one more entry of the file should come in the view)
How can I do that?
I have no clue about it!
Thanks
You will need directory listing enabled on the remote server, and parse the HTML output in your app. (Or create an ex. Server side script (PHP?) that returns a directory listing)
Check out any of the availible http clients for Android, like third party OkHTTP, or LoopJ AsyncHTTPClient (I always liked his one) or HttpURLConnection which comes packed with Android.
Related
I have to download a file from Amazon S3 to Android APP via Servlet and I have to hide the URL.
Is there a solution to download a file without Android App know the path?
THANKS :)
In this case you need a special layer - so called "API" displayed as Servlet on the picture. Your app passes some param like id of a picture to an API method and API returns a picture in response. Its up to API how it will dl the image from AWS but the app will never know the real url. API is a web-service, a kind of web-site which could be seen only programmatically using HTTP-requests and is a job for web-developers.
I'm not much of a web developer so I can't explain how to develop it using ElasticBeanstalk or anything else. However the main idea is that you have to assign some unique id to every file you upload to amazon. Every unique id must be related (correspond) to a particular file's url. These relations must be known to your API/server/backend only (for instance - url "http:/amazon.com/file01" will be stored as a file with id 1 and so on). Your android app should know only the id of a file (for instance - app requests a list of files from your API and gets a JSON array of available files like "{files:[{id:1,name:"file01"},{id:2,name:"file02"},{id:3,name:"file03"}...]}). So when app requests a file it "says" to API only the id (1 or 2 or 3 showing to user only a file name), the server then looks for an url of that file matching given id, downloads it and sends it to your app or creates a buffer stream so server sends received data from amazon to app and app "thinks" that file comes from your API/server (but it will be downloaded from amazon in real). Your API/server should be something like a proxy server. Also you could use FireBase Real DataBase for your needs, like to store id<->url relations there.
I want to create Android app where I have items with images and descriptions - only for information, no interact. How can I download layout from server and show remote data? I'm newby - I can create simple apps, but this problem is not solved in Internet. I search in Google, Youtube but I can't find anything.
First you need to create a layout in your app (you cannot parse layout from server only data can be parsed), then connect your layout items to loading data from server.
You can check out an basic example to populate list view from server from here and here
I’m making an Android app that lets users store a bunch of video files on disk after retrieving them from an RSS feed. The app will run in a web view. I’m fetching the videos with XHR requests.
How can I send a message from javascript to java containing the data for the downloaded files?
I mean … I could store the files within indexdb within the web view browser. However, browser cache APIs like app cache and indexdb have strict quotas. I don’t think I can store many video files within those quotas.
And it also looks like the quota updater API is deprecated, so I can’t alter web storage quotas: http://developer.android.com/reference/android/webkit/WebStorage.QuotaUpdater.html
It seems like my only alternative is to send file data from the web view as a message for java code to handle (and store the file on local disk). Later, I can have java tell the web view that it had previously stored data. How can I send such a message using the android API?
I’m fetching the videos with XHR requests
Off the cuff, I wouldn't. Usually video files are large, and if you really want them downloaded, you can't just do that from an activity, whether powered by a WebView or not.
It seems like my only alternative is to send file data from the web view as a message for java code to handle (and store the file on local disk). Later, I can have java tell the web view that it had previously stored data. How can I send such a message using the android API?
Use addJavascriptInterface() on the WebView to inject a Java object into the JavaScript environment of the WebView. On that Java object, have a method that will download the video file, using a Service (perhaps an IntentService) or DownloadManager, given the URL to the file. Not only will this solve your issue of how to get the file stored locally on the device, but it is more likely that the video will actually successfully download if the user navigates away from your app while the download is going on.
Well, I have uploaded an android application on Google play store which shows live channel of my country.
I just want to avoid Database call for fetching URLs for live channel. Now alternate in my mind is that upload an XML file so that android app reads URLs from that XML and if URLs are changed later, i can upload the new XML to Google play store again ?
Now how easy is it to upload to Google Play Store, will it be automatic update for users?
What are other alternatives for fetching Streaming URL from Database or XML ?
It's obvious, that you shouldn't hardcode the list of channels inside the APK (by putting it inside the XML or DB with the assets), nobody wants to update the app just because this list was changed. The easiest way is to put XML file on some server (you may want to take a look on Amazon Web Services, they have great solution for keeping static content) and pull it either on the first run or on demand. Also you may want to use GCM to send either the message that list was updated or, if the size of the list is not very big, you can send the list itself via this service.
You want to persist some information from server into your device:
Database
SharedPreferences
File ( which could be XML or any other format like JSON, even you can save one file per
channel with that channel name to avoid parsing, I suggest json format)
My app downloads some assets from my server using an AsyncTask and I put them in a folder on the SD Card. Then, I use these assets in my buttons backgrounds. Everything works, but I'm wondering the best practice to use when I change my assets on the server side. In fact, at the moment, I'm not able to know if the server asset is a new one compared to the one stored locally. However, I was thinking about two possible solutions:
1) The app checks the server for new files, e.g. twice a day. If new files are there, then download them and upgrade the storage locally. In this case: how can I get the time difference between the local and the server file? In other words, how can I know that the server asset is a new one compared to the local one?
2) The server send a notification to the client when a new file is available. How can I manage that?
What is the best choice between the two above?
You can have an assets version number for your assets. Every time your app starts, you can request the latest assets version number. if its larger than the version number you have stored, you know that the images have changed and you can download the latest images. Every time images changes in the server, make sure you increase the version number.
You should also store the version number when you retrieve assets from the server.
I think option 2) ("server send a notification to the client when a new file is available") would require running a Service on the client in order to "listen" to the notification --> This is overkill
What I would do is similar to your option 1) except it is independent from the client and server's clocks:
Version your assets, and store:
On server side, in a txt or xml file, the latest version of each asset available on the server
On client side, the current version of each asset the version number of the latest
On client side, you would then periodically retrieve the txt/xml file, and determine if you need to download new assets.
You could add some code on the server to compute the MD5 sum of a file, and then from the Android app, make a request to e.g. http://hostname/getMD5?file=myfile.abc, and if the MD5 sum differ from the local one, download the file again.
As for notifying the phone, I don't think that's possible. But it might be OK to poll every 30 mins or so, since you only need to fetch a short string.
Add a version file to your server, something simple such as like this one would work:
version.txt:
image001.bmp 3
image002.bmp 1
image003.bmp 1
You can download this file as first thing when you connect to server and parse it. Then if you notice a newer version on server, download updated files.