java - Why is the button.setText() shows error -


i made function called every 1 second , within function wrote

mybutton.settext("stop"); 

now works great without code,but whenever write code,the mobile make test on shows message "app has stopped working" i've been looking solution 3 days now,help appreciated!

this code

check_time = new timertask() { @override                         public void run() {                                  mybutton.settext("stop");                              calendar lo_calender = calendar.getinstance();                             int current_h = lo_calender.get(calendar.hour);                             int current_m = lo_calender.get(calendar.minute);                             if (h_towake == current_h && m_towake == current_m) {                                 out.println("ring");                                  alarm();                                  //return;                             } else {                                 out.println("no ring!");                             }                         }                     };                     time.schedule(check_time, 0, 1000); } 

you cannot touch ui background thread. use asynctask http://developer.android.com/reference/android/os/asynctask.html


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -