Write Toast.maketext (Getapplicationcontext (), "SD does not exist", toast.length_short) in the Onhandleintent method in your own Intentsevice inheritance class. Show ( ); When there is no prompt, logcat "Sending message to a Handler on a dead thread" error. After the error from the Internet to understand the reason that when a thread's message loop has exited, you can no longer send a message to the error. After having found a solution from a Web site, and the cause of the error.
The problem here is, that's creating a Toast inside a thread that's managed by the Intentservice. The system would use the Handler associated with this thread to show and hide the Toast.
First the Toast would be shown correctly, if the system tries to hide it, after the Onhandleintent method had finishe D, the error "sending message to a Handler on a dead thread" would be thrown because the thread on which the Toast was Crea Ted is no longer valid, and the Toast would not disappear.
The problem here is that you are creating a toast internal thread that is managed by Intentservice. The system will use the handler associated with this thread to show and hide the toast. First, the toast will be displayed correctly, but when the system tries to hide it, the Onhandleintent method is complete, and the error "sending message to a Handler on a dead thread" will be thrown, Because the thread on which the toast was created is no longer valid, and the toast does not disappear.
Workaround:
Create a handler to post messages to the main thread handler Mhandler = new Handler (Getmainlooper ()); Mhandler.post (New Runnable () {@Override public void run () {Toast.maketext (getapplicationcontext (), "test", Toast.length_short). Show (); } });
Reference: http://www.xuebuyuan.com/36739.html
Intentservice using Toask error sending message to a Handler on a dead thread