I have the following dilemma, I have an Android Application that POST a request into a mysql db via php using HTTP Client, I’m using JSON to extract the response.
Here’s a rough view of that scenario,
I have a ArrayList that gets populated using the response, lets call it the Main Menu
Upon clicking an item from the Main Menu, I would send a POST request and wait for the response from the server,
So here’s my question, which one is advisable and more reliable,
-
Upon running the application/activity, I would download everything and hide the irrelevant items, enabling/disabling them upon request, eg. I’m just showing the first relevant items for the Menu, or
-
Request to the server the information details of the selected Menu Item only upon request? Like, just download the Main Menu, and the default items for the Main Menu id 1
Are there any other available approach, what are the pros and cons of each approach, which one is reliable and more efficient?
Depends on the length of the list but some things to consider…
How long is it going to take to retrieve and populate the menu before the user gets a response?
Latency is the killer in mobile (3G, 2G etc), so one larger request may be quicker than multiple smaller ones.
Multiple smaller requests will consume more battery power as the phone will have to wake the radio from sleep and this is consumes more power than waking one and a larger response. (there was some good research published on this recently)