Pergunta

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

Foi útil?

Solução 3

implement LocationListener instead of using TimerTask

Outras dicas

Just use runOnUiThread():

runOnUiThread(new Runnable() {
    public void run() {
        Toast.makeText(yourContext, "Data: ", Toast.LENGTH_SHORT).show();
    }
});
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top