سؤال

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

هل كانت مفيدة؟

المحلول 3

implement LocationListener instead of using TimerTask

نصائح أخرى

Just use runOnUiThread():

runOnUiThread(new Runnable() {
    public void run() {
        Toast.makeText(yourContext, "Data: ", Toast.LENGTH_SHORT).show();
    }
});
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top