Possible to integrate while loop into Android studio network connect? - android

I am facing a small issue with the android studio net work connect sample code.
Basically the code does exactly what i need, Press a button, it will fetch raw html a predetermined http.
However i was wondering if it is possible to make a while loop such that i do not need to press on the fetch button every time i want to get the data.
Regards.
http://developer.android.com/samples/NetworkConnect/index.html

What do you want exactly ? Do you want to refresh the web page or to check network connection ?
It seems you looking for refreshing the web page some period time.
While loop doesn't make sense. I suggest you to use Thread Handler or Timer.
Refer this link
you may get some ideas.

Related

Load huge dataset from cloud in my ListView - Android

I have read a lot of SO answers asking a similar question, but I believe my question is different. I have to load around 70-80K records from the cloud and display it to the user in a ListView. A few things that I want to be done :
I don't want to use a load more Button or load more objects when the user scrolls as I have a index from A-Z so the user could start my application and click on Z and the data should be present/available to him.
I have considered pre fetching the data using a splash screen but I was wondering if there is really any other optimised method to fetch such huge data.
I don't want to hang up the UI thread with the Loading progress bar.
I agree that this may be too much to ask for but I am just trying to see if someone has a very efficient way of doing this. I am open to ideas involving modifications in the backend on web service as well, so if you have an efficient way of achieving this using some modifications on the web service, that is also fine for me.
If it helps, look at your default contacts app, it has all the data ready and available to you when you open it. You can directly use the index to navigate to Z section. Just assume the same with 70k entries in the app.
Thanks in advance!
Here is the best solutions I figured out with the help of Tamal Mukherjee and Roman Nurik.
Tamal's solution :
Just load 5-10 rows/letter. Add a 'more' button or handle scroll event and load dynamically. Use SQLite to store data. Use background threads to fill up the db. 
Roman Nurik's soltuion :
With 80k rows, that's well over 1000 items per letter in the alphabet. Seems like you'll need a lot more than letter indexing to make this UI usable. Why not offer filter-as-you-type? That'll result in more HTTP requests but might result in a better UX.
So i guess my implementation will be a combination of the both.
Please follow this step:-
1- Call API on splashscreen using IntentService.
2- Use static broadCasting and save API response into sqlitedb using ORMLite in onRecieve() method of BroadCastReciever.
3- Make sure there should be separate class for receiver.
4- Use Loader Manager for updating ListView.

Get data from webservice and put on map

I am doing an application on Android that gets locations from a webservice and puts it on a map. The app should do it every 15 seconds. What is the best way to do this?The communicaton with the webservice is made using REST architecture and the webservice returns a JSON. Should i use a Service or AsyncTask? thanks
You'll for sure see different opinions around here regarding this topic, but I've been using ExecutorServices for a while and they work really nice. Don't forget to stop it whenever the activity pauses.
Remainder: if the application should be an always running thing (for example a GPS navigation, or some type of location based social gaming) then you might want to use a Service that will also use an ExecutorService and don't forget to put a Notification letting users know that it's still running and that they can cancel if they wish to.

How to get starting and ending time of each download?

I am implementing one application related to downloads.
Based upon my requirement I want to get start and ending time each downloads.
For example the user downloads a app from android market after installing my app, then i need to get starting and ending time related to that download.
If any one know the solution please help me.
Thanks in advance.
Don't put direct link for download. Just put a php file which gets the address of file and let the user download it. In that case you can easily get the time with php. For the finish time it is not in your access but the best way is to use javascript on page which sends report of download to you via AJAX
Assuming that you want to display the start download time and the end download time the solution that comes to my mind is of using a AsyncTask where the start time can be displayed within the onPreExecute(), perform the download of app operation in doInBackground() and when the download finishes the time can be displayed in the onPostExecute(). HTH.

how to fix a particular time interval for sending data from android mobile to a webserver?

i have been using eclipse to create an app on android for sending data to a server through GPS.
the app that i have developed is sending the data for every second .. but i cant change the time intervals... can anyone tell me a way or code to send data from my app to server for once in every 2 minutes.
As you are using Java, the best option you have is of Thread.
And use sleep() method.
Try this Link
Use alarm manager..

parse xml after some time android

In my app i need to parse the XML file & display info on activity. just like stock market as & when information at server got updated i need to parse the xml & display the info.I need to hit the server after 5 minutes & display the updated info on activity. I have tried using AsyncTask & timer but something going wrong.If any one is having demo then please provide link,tutorial..
It's extermely urgent..
thnx for any help....
Sounds like you want to run a polling loop in the background? You should be able to use a timer to kick off the check and an async task to actually request/parse. There's a bit of complexity in setting up the timer handling, the accepted answer to this question should help however:
How to get XML using AsyncTask and Timer?

Categories

Resources