Denoteone
Denoteone

Reputation: 4055

Reload current activity every 10 mins

I am not sure the best way to accomplish this but I would like to reload my app's current activity every 10 mins. So I can show the most current data.

If there is some timer class I can create to run a method every 10mins that does the following:

finish();
startActivity(getIntent());

My Main reason for doing this is to reload so the activity does the http call again gets the data and adds it to a list view and gives the effect of it UPDATING every 10 mins.

Upvotes: 0

Views: 1235

Answers (2)

neteinstein
neteinstein

Reputation: 17613

Use AlarmManager, TimerTask i don't think is the best approach.

You can check a snippet here:

https://stackoverflow.com/a/1082836/327011

Upvotes: 1

Dinesh Prajapati
Dinesh Prajapati

Reputation: 9510

To make the updating listview you do not need to start the activity again. it will be bad user exeperience. you can put that in the timertask and for every 10 mins call the HTTP call function and set the adapter in the same function.. you work is over.

Upvotes: 1

Related Questions