android - how to toast inside timerTask run.Exception is uncaught handler -


@override public int onstartcommand(intent intent, int flags, int startid) {     toast.maketext(this, "my service started", toast.length_long).show();             time=long.parselong(intent.getstringextra("time"));     toast.maketext(this, ""+time, toast.length_long).show();     timer=new timer();     timertask timertask=new timertask() {         @override         public void run() {             calendar c = calendar.getinstance();             int minute = c.get(calendar.minute);             if(minute==time) {                  log.d("alarmservice", "timer");                 toast.maketext(getapplicationcontext(),"ringing",toast.length_short);             }         }     };     timer.scheduleatfixedrate(timertask, 0, 1000*2);      return super.onstartcommand(intent, flags, startid); } 

how toast inside timertask run.exception uncaught handler

because showing toast run method of timertask execute on non-ui thread.

so fix issue use handler or runonuithread show toast run method


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -