Question

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

Was it helpful?

Solution 3

implement LocationListener instead of using TimerTask

OTHER TIPS

Just use runOnUiThread():

runOnUiThread(new Runnable() {
    public void run() {
        Toast.makeText(yourContext, "Data: ", Toast.LENGTH_SHORT).show();
    }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top