Android : Timer behaving strangely in Android

on Saturday, November 1, 2014


I'm setting a Timer to update my Fragment, with the code



private List<Item> items;
...

autoUpdate = new Timer();
autoUpdate.schedule(new TimerTask() {
@Override
public void run() {
update();
}
}, seconds*1000, seconds*1000);

public void update() {
if (items == null){
Log.d("test", "items are null");
}
}


When the Timer calls the update method, items always appear as null. However if I call the same method in any other way (like by pressing a button), the same items do not appear as null! Any ideas?


0 comments:

Post a Comment