我使用此代码从我的 开始一个新游戏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。