Domanda

I am implementing an application that get the location data in certain intervals of time and checks the location got is the destination. If current location is the destination I want to Toast or update a TextField. I used TimerTask for this. But it is not giving me the correct output. While I searched I saw that TimerTask cannot handle changes in the UI. Is there any way to solve my problem? I want to check in certain intervals and want to update UI

È stato utile?

Soluzione 3

implement LocationListener instead of using TimerTask

Altri suggerimenti

Just use runOnUiThread():

runOnUiThread(new Runnable() {
    public void run() {
        Toast.makeText(yourContext, "Data: ", Toast.LENGTH_SHORT).show();
    }
});
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top