我的应用程序正常运行,但我遇到以下错误:
10-04 14:04:38.182: W/MessageQueue(8625): Handler (android.media.MediaPlayer$EventHandler){416ad6b0} sending message to a Handler on a dead thread
10-04 14:04:38.182: W/MessageQueue(8625): java.lang.RuntimeException: Handler (android.media.MediaPlayer$EventHandler) {416ad6b0} sending message to a Handler on a dead thread
10-04 14:04:38.182: W/MessageQueue(8625): at android.os.MessageQueue.enqueueMessage(MessageQueue.java:196)
10-04 14:04:38.182: W/MessageQueue(8625): at android.os.Handler.sendMessageAtTime(Handler.java:473)
10-04 14:04:38.182: W/MessageQueue(8625): at android.os.Handler.sendMessageDelayed(Handler.java:446)
10-04 14:04:38.182: W/MessageQueue(8625): at android.os.Handler.sendMessage (Handler.java:383)
10-04 14:04:38.182: W/MessageQueue(8625): at android.media.MediaPlayer.postEventFromNative(MediaPlayer.java:1898)
10-04 14:04:38.182: W/MessageQueue(8625): at dalvik.system.NativeStart.run(Native Method)
10-04 14:04:38.182: V/MediaPlayer(8625): back from callback
我已经看到this thread和建议的解决方法,但它对我不起作用。
有人有另一种解决方案吗?
答案 0 :(得分:4)
// 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(), "hello", Toast.LENGTH_SHORT).show();
}
});
尝试此代码希望它有所帮助
答案 1 :(得分:-1)
您可以在GCM示例应用中使用Handler
而不是在GCMIntentService
中使用BroadcastReceiver
,而不是在此答案中建议:Update TextView from GCMIntentService in Methods onRegistered and onUnregistered