We've written an app for Android (and iOS), and it allows users to upload photos to our REST server. The issue we're hitting is that sometimes the users are in places with terrible cell signal and no WIFI. So, I was wondering if there was either a prebuilt solution, or a recommended path to take to defer these uploads until later if there are only lackluster network options available.
Right now on Android I'm using an AsyncTask to upload a stream representation of a captured image. The image's maximum dimension is cropped to 1280, and the other is aspect scaled, so the images aren't massive.
The user may have no signal for up to 2 hours I imagine, so it'd not need to attempt to upload every minute. Additionally, there may be multiple uploads, so some kind of queue is needed, I think.
I'm not positive what the iOS app is leveraging, but I can find out if it helps.
The best option would be to save the photo to the SD card and put the path to it in a database. The database here acts like a queue. So whenever the user has access to internet, the app can check whether there are any entries in the database and start uploading. Once you upload the photo, you delete that record from the database.
Now, as far as the upload is concerned, I recommend doing it in a Service as opposed to an AsyncTask. This way you can use an AlarmManager to call the service at periodic intervals and check whether there is anything to upload.
I used this method in one of my applications but for documents. It works like a charm. Hope that helped.
In iOS I used ASIHTTPRequest, but at the moment you can find other solutions (MKNetworkKit). I did an application exactly like what you are doing so what I did was:
Check if there is internet, if yes continue, otherwise stop.
Try to send one photo, if succeed go to the next one, otherwise leave the photo on the queue and go to the next photo.
Repeat process.
Let's imagine the user putted 20 photos on the queue, and start the process, at the end of the day he could check again what succeed and what didn't. Of course he could re-send what failed in the first place.
Related
I am trying to pull videos from firebase storage and put them into a slideshow on my Android app but the videos take so long to load. Does anyone have any alternatives or ways to speed up the data download?
You can store your files in the Regional Storage, such as us-east1.
Please refer to https://cloud.google.com/storage/docs/bucket-locations and change your bucket's region to most closest place to you.
One thing you can do is split your video in smaller chunks when you are uploading
then download chunks one by one as slideshow plays.
It is a good idea because by this way you or your user don't have to wait for whole file. you can start playing videos as soon as your first chunk is available and then continue downloading next one's in background.
When you chunk video files, you reduce the risk of timeouts. If a small chunk fails to download for whatever reason, you can automatically retry only that chunk, instead of having to restart the entire download.
and yes when firebase is downloading it will do chucking but it'll be random and not much useful to you now because firebase'll do it for download and it'll signal you when file is fully downloaded to play.
Every streaming service does this. even though multithread downloaders also do the same.
you can google to find optimal chunk size and more about it.
I just googled and it looks good.
https://www.limelight.com/blog/multiple-solutions-for-low-latency-live-video-streaming/
I am attempting to build an android app and in that app I have a list view, which I would like to have thumbnail images in. The images are stored on a server, and they are all in the same folder (e.g. http://myserverlocation.com/images/dining/myImage1.jpg,myImage2.jpg, etc). What I want to know, is if there is an easy way to get all the images (approx 25) using ONE http request, or connection. What I want to avoid is making 25 http requests, one for each image, to get all the thumbnails. I'm familiar with AsyncTask, and BitMap, but I haven't seen anything on this site (or the internet) that talks about getting multiple images with one call. I was hoping someone here would have an answer for me, as to whether or not this is possible. I'm open to any suggestions on how I might be able to accomplish this task, without using all the phones resources and/or memory.
Thank you!
If you are controlling the web service, I would highly recommended storing a zip file and retrieving that. I believe that Android likes to play with bzip, but that may be wrong.
Either way, I remember reading on the Android Dev site or watching a Google IO talk and they suggested to zip it before you ship it.
From what I know, you can't get the exact number of users which downloaded your app, unless you're connected to your Google plus account. Is that true? (I haven't yet got a google play (android market) account, my app isn't yet up on the market, so i just wanna make sure i'm saying valid things here.)
Is there any way i could programmatically get the number of downloads, preferably in real time?
From what I've found, there isn't an API for the market which let's me do this. So how can this be accomplished?
I need to take that value and in real time update a graph on my website and blog.
Can anyone come up with a workaround for this? One thing i was thinking of was: to either make a Firefox extension which on my home machine, automatically connects to my Google plus account, takes the required value and updates the page via ftp or something, or instead of Firefox extension i could use PHP locally to do the parsing and whatnot. But i'd need to keep my home machine always on, which i don't really want to.
Any other ideas? I really need that exact value, and i need it to be automated :)
When the user downloads the app, you could have it do a callback to a script on your site that does a tally for you. The app should, obviously, only call this on the first run (but, depending on how you implemented it, would probably be called on each refresh of the app's cache/data). If you don't have a service that needs registration, you could have it done in the background.
Not possible by default. The only figures that do exist are only updated daily at most.
You would need to devise your own way to count downloads such as requiring your users to register on your own service.
I'm new in development of applications for Android so I'm asking those questions for know which is better way to make RSS reader app. I have a server that downloads and stores on database news from Yahoo. On this database are stored title, content, publication date and link of news. Than I'm making HTTP POST to server to download news to Android. Data from server to android are passed in Json.
Can people, who already had developed an application like this, answer my questions?
Should I pass all list of news in one response to POST or it's better to make it's better to make several POSTs to get the same list? I'm asking this question because response from server may be too big and I don't know which is a better way to transmit it.
Comment system is the feature of my app. So need I to create a authentication system or it's possible to make it basing on ID of phone?
Another thing I need to do is to alert user when new news has appeared on server. I don't have idea how to do it with HTTP POST? Need I send to server list of nees that I have on Android?
Thank you for attention.
Here are the answers for your respective wuestions
1) This depends more on kind of UI you chose for your Android application. In my perspective you should go for multi-page (like prev-next links on bottom of screen) UI for your reader. And you should cache the results of previous page as well as next page in you app (so this also means to fetch selective results only) so that when user clicks on next/prev button the responsiveness of you application is good.
2) Ideally you app should ask for show a pop-up dialog asking to authenticate for commenting. You should use something like http://developer.android.com/reference/android/accounts/AccountManager.html to store these credentials so that from next time you do not ask the credentials again once authentication is successful.
3) In this case you should look at http://code.google.com/android/c2dm/
Polling is surely not the way to go :)
See it depends on how big your file is and more importantly how quickly do you need it.
More requests will certainly increase the latency. What generally you should go for is for one request.
But it again depends, I was once working on an android app and had the same problem. But in my case I split it into 2 requests. One so that I get initial data quickly and can disply to the user. Later with another request I can get the remaining data. So see wh1t suits you more.
Also how many requests will you have to make on an average in an hour. More polling will surely eat your battery a lot. If pushing can help you, try seeing if google's C2DM can be of any help.
For Rss parser ibm has an excellent link at http://www.ibm.com/developerworks/xml/tutorials/x-androidrss/index.html
POST vs GET - POST is meant to change state of server, whole GET is for reading results -
you should use GET to retrieve news, and POST to post comments
Use timastamp to retrieve news from some moment, update timestamp on the device
with latest received news timestamp - this will save traffic for your users and your server. First update will get everything ( you may also put a limiton amopunt of news retrieved in single batch )
everything based on something present on phone is not strong. however, you can use some kind of open id (there are a lot of providers, and most of your users will have google account) provider. In my highscore system I just hash incoming entries with some secret present in APK - this is not very secure, but data are not that valuable and there were no hack attepßts so far.
Every push alert requires active polling from device - also your application shall ask via get request something like "are there new entries since last timestamp" ( but if you already do this, you may as well just download them ) - the alert user via usual android means ( widget, status bar, vibration, playing starwars imperial march... )
Do they keep an online user list in a database and update it with every login and logout event, and run queries for online friends?
What about scalability?
Are there better solutions?
If you try to either store presence in a traditional database, or poll for changes to anything, you're going to have a tough time scaling your presence system. Start with one of the open source XMPP servers, pull it apart, and see how it works. Each one of them scales differently, but at least you'll understand more about where you need to start.