0

我使用此代码从我的 开始一个新游戏MainMenu,一切正常,但是当游戏完成时,用户会得到一个弹出窗口(只是另一个以 命名GameFinished的Activity Theme.Dialog)。用户可以选择是否要再次玩游戏或返回MainMenu. 这也可以正常工作,但是当我开始另一个游戏时,我MainMenu什么也没发生,调试器显示该行已执行。

视觉指南:

A --> B --> C --完成--> B --完成--> A

之后我不能这样:

A --> B

public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {

    if (id == 0) {
                        startActivity(new Intent(GameMenu.this, GuessFlag.class));
                    } else if (id == 1) {
                        startActivity(new Intent(GameMenu.this,
                                MovieQuestions.class));
                    } else if (id == 2) {
                        startActivity(new Intent(GameMenu.this, SimpleMath.class));
                    } else if (id == 3) {
                        startActivity(new Intent(GameMenu.this, TickTacToe.class));
                    }
                }

我在几周内唯一添加的就是这条线,所以我Tapifier可以工作:

StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
        .permitAll().build();

StrictMode.setThreadPolicy(policy);

这是我的(非常大的)logcat:

01-16 17:17:28.845: E/ActivityThread(9311): Activity com.obattech.twoplayergame.games.MovieQuestions has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@42342078 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:28.845: E/ActivityThread(9311): android.app.IntentReceiverLeaked: Activity com.obattech.twoplayergame.games.MovieQuestions has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@42342078 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:792)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:593)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1254)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1241)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1235)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:372)
01-16 17:17:28.845: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.<init>(MultiPhoneWindowEvent.java:332)
01-16 17:17:28.845: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.installDecor(MultiPhoneWindowEvent.java:176)
01-16 17:17:28.845: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:28.845: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:28.845: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3175)
01-16 17:17:28.845: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:304)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.Activity.setContentView(Activity.java:1924)
01-16 17:17:28.845: E/ActivityThread(9311):     at com.obattech.twoplayergame.games.MovieQuestions.onCreate(MovieQuestions.java:45)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.Activity.performCreate(Activity.java:5206)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.ActivityThread.access$600(ActivityThread.java:140)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.os.Looper.loop(Looper.java:137)
01-16 17:17:28.845: E/ActivityThread(9311):     at android.app.ActivityThread.main(ActivityThread.java:4898)
01-16 17:17:28.845: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:28.845: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:28.845: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
01-16 17:17:28.845: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
01-16 17:17:28.845: E/ActivityThread(9311):     at dalvik.system.NativeStart.main(Native Method)
01-16 17:17:29.900: E/ActivityThread(9311): Activity com.obattech.twoplayergame.games.SimpleMath has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@423555f8 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:29.900: E/ActivityThread(9311): android.app.IntentReceiverLeaked: Activity com.obattech.twoplayergame.games.SimpleMath has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@423555f8 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:792)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:593)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1254)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1241)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1235)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:372)
01-16 17:17:29.900: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.<init>(MultiPhoneWindowEvent.java:332)
01-16 17:17:29.900: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.installDecor(MultiPhoneWindowEvent.java:176)
01-16 17:17:29.900: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:29.900: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:29.900: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3175)
01-16 17:17:29.900: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:304)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.Activity.setContentView(Activity.java:1924)
01-16 17:17:29.900: E/ActivityThread(9311):     at com.obattech.twoplayergame.games.SimpleMath.onCreate(SimpleMath.java:46)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.Activity.performCreate(Activity.java:5206)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.ActivityThread.access$600(ActivityThread.java:140)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.os.Looper.loop(Looper.java:137)
01-16 17:17:29.900: E/ActivityThread(9311):     at android.app.ActivityThread.main(ActivityThread.java:4898)
01-16 17:17:29.900: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:29.900: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:29.900: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
01-16 17:17:29.900: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
01-16 17:17:29.900: E/ActivityThread(9311):     at dalvik.system.NativeStart.main(Native Method)
01-16 17:17:30.520: E/ActivityThread(9311): Activity com.obattech.twoplayergame.games.MovieQuestions has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@4294f240 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:30.520: E/ActivityThread(9311): android.app.IntentReceiverLeaked: Activity com.obattech.twoplayergame.games.MovieQuestions has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@4294f240 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:792)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:593)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1254)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1241)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1235)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:372)
01-16 17:17:30.520: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.<init>(MultiPhoneWindowEvent.java:332)
01-16 17:17:30.520: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.installDecor(MultiPhoneWindowEvent.java:176)
01-16 17:17:30.520: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:30.520: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:30.520: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3175)
01-16 17:17:30.520: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:304)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.Activity.setContentView(Activity.java:1924)
01-16 17:17:30.520: E/ActivityThread(9311):     at com.obattech.twoplayergame.games.MovieQuestions.onCreate(MovieQuestions.java:45)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.Activity.performCreate(Activity.java:5206)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.ActivityThread.access$600(ActivityThread.java:140)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.os.Looper.loop(Looper.java:137)
01-16 17:17:30.520: E/ActivityThread(9311):     at android.app.ActivityThread.main(ActivityThread.java:4898)
01-16 17:17:30.520: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:30.520: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:30.520: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
01-16 17:17:30.520: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
01-16 17:17:30.520: E/ActivityThread(9311):     at dalvik.system.NativeStart.main(Native Method)
01-16 17:17:30.825: E/ActivityThread(9311): Activity com.obattech.twoplayergame.games.GuessFlag has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@4296a908 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:30.825: E/ActivityThread(9311): android.app.IntentReceiverLeaked: Activity com.obattech.twoplayergame.games.GuessFlag has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@4296a908 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:792)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:593)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1254)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1241)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1235)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:372)
01-16 17:17:30.825: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.<init>(MultiPhoneWindowEvent.java:332)
01-16 17:17:30.825: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.installDecor(MultiPhoneWindowEvent.java:176)
01-16 17:17:30.825: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:30.825: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:30.825: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3175)
01-16 17:17:30.825: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:304)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.Activity.setContentView(Activity.java:1924)
01-16 17:17:30.825: E/ActivityThread(9311):     at com.obattech.twoplayergame.games.GuessFlag.onCreate(GuessFlag.java:46)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.Activity.performCreate(Activity.java:5206)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.ActivityThread.access$600(ActivityThread.java:140)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.os.Looper.loop(Looper.java:137)
01-16 17:17:30.825: E/ActivityThread(9311):     at android.app.ActivityThread.main(ActivityThread.java:4898)
01-16 17:17:30.825: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:30.825: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:30.825: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
01-16 17:17:30.825: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
01-16 17:17:30.825: E/ActivityThread(9311):     at dalvik.system.NativeStart.main(Native Method)
01-16 17:17:31.225: E/ActivityThread(9311): Activity com.obattech.twoplayergame.games.SimpleMath has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@429858b0 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:31.225: E/ActivityThread(9311): android.app.IntentReceiverLeaked: Activity com.obattech.twoplayergame.games.SimpleMath has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@429858b0 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:792)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:593)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1254)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1241)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1235)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:372)
01-16 17:17:31.225: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.<init>(MultiPhoneWindowEvent.java:332)
01-16 17:17:31.225: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.installDecor(MultiPhoneWindowEvent.java:176)
01-16 17:17:31.225: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:31.225: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:31.225: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3175)
01-16 17:17:31.225: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:304)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.Activity.setContentView(Activity.java:1924)
01-16 17:17:31.225: E/ActivityThread(9311):     at com.obattech.twoplayergame.games.SimpleMath.onCreate(SimpleMath.java:46)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.Activity.performCreate(Activity.java:5206)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.ActivityThread.access$600(ActivityThread.java:140)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.os.Looper.loop(Looper.java:137)
01-16 17:17:31.225: E/ActivityThread(9311):     at android.app.ActivityThread.main(ActivityThread.java:4898)
01-16 17:17:31.225: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:31.225: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:31.225: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
01-16 17:17:31.225: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
01-16 17:17:31.225: E/ActivityThread(9311):     at dalvik.system.NativeStart.main(Native Method)
01-16 17:17:31.500: E/ActivityThread(9311): Activity com.obattech.twoplayergame.games.GuessFlag has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@429a0de0 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:31.500: E/ActivityThread(9311): android.app.IntentReceiverLeaked: Activity com.obattech.twoplayergame.games.GuessFlag has leaked IntentReceiver com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent$1@429a0de0 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:792)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:593)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1254)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1241)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1235)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:372)
01-16 17:17:31.500: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.<init>(MultiPhoneWindowEvent.java:332)
01-16 17:17:31.500: E/ActivityThread(9311):     at com.android.internal.policy.impl.multiwindow.MultiPhoneWindowEvent.installDecor(MultiPhoneWindowEvent.java:176)
01-16 17:17:31.500: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:31.500: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:31.500: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3175)
01-16 17:17:31.500: E/ActivityThread(9311):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:304)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.Activity.setContentView(Activity.java:1924)
01-16 17:17:31.500: E/ActivityThread(9311):     at com.obattech.twoplayergame.games.GuessFlag.onCreate(GuessFlag.java:46)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.Activity.performCreate(Activity.java:5206)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.ActivityThread.access$600(ActivityThread.java:140)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.os.Looper.loop(Looper.java:137)
01-16 17:17:31.500: E/ActivityThread(9311):     at android.app.ActivityThread.main(ActivityThread.java:4898)
01-16 17:17:31.500: E/ActivityThread(9311):     at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:17:31.500: E/ActivityThread(9311):     at java.lang.reflect.Method.invoke(Method.java:511)
01-16 17:17:31.500: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
01-16 17:17:31.500: E/ActivityThread(9311):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
01-16 17:17:31.500: E/ActivityThread(9311):     at dalvik.system.NativeStart.main(Native Method)

简单数学:

@Override
    protected void onCreate(Bundle savedInstanceState) {

            requestWindowFeature(Window.FEATURE_NO_TITLE);
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_game_simpemath);


        }

protected void onResume() {
    super.onResume();
    if (AppData.questionsLoaded) {
        AppData.questionsLoaded  = false;
        runGame();
    }

    if (AppData.restartGame) {
        AppData.restartGame = false;
        finish();
        startActivity(new Intent(SimpleMath.this, TickTacToe.class));
    }

    if(AppData.finishMe){
        finish();
    }

}

PlayAgain(游戏结束时接听电话):

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_game_gamefinished);

    Window window = this.getWindow();
    window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);

    android.view.WindowManager.LayoutParams params = getWindow()
            .getAttributes();
    params.width = android.view.WindowManager.LayoutParams.MATCH_PARENT;
    getWindow().setAttributes(
            (android.view.WindowManager.LayoutParams) params);

            setListeners();
}

public void setListeners() {

    button_restart.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            AppData.restartGame = true;
            finish();
        }
    });

    button_mainmenu.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            AppData.finishMe = true;
            finish();
        }
    });
}

唯一相关的其他事情是我使用了 AsyncTask 和 Handler。

4

2 回答 2

5

ObAt,我的应用程序中有完全相同的错误。您写道您不使用 IntentReceiver,但这可能不是真的。

似乎您正在使用三星设备的特殊功能 - MultiWindow,所以如果您在清单中注册了意图过滤器,就像我一样:

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <!-- SAMSUNG MULTI-WINDOW -->
        <category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
    </intent-filter>

    <!-- SAMSUNG MULTI-WINDOW -->   
    <meta-data android:name="com.sec.minimode.icon.portrait.normal"
        android:resource="@drawable/ic_launcher" />
    <meta-data android:name="com.sec.minimode.icon.landscape.normal"
        android:resource="@drawable/ic_launcher" />

那么三星设备可能会在后台自行注册 IntentReceiver 以正确处理与 MultiWindow 功能相关的一些任务。我在日志中看到这个错误几个月,它从来没有任何问题。所以我只是忽略了这一点,直到三星在他们这边解决了这个问题。这就是我的看法

于 2013-02-20T18:22:22.430 回答
0

根据您的错误,您正在泄漏您之前注册的 IntentReceiver。

您需要取消注册 IntentReceiver,该onPause方法将是为您的SimpleMath活动执行此操作的好地方。

@Override
protected void onPause() {
    super.onPause();
    unregister(); //  here
}
于 2013-01-16T16:24:46.127 回答