所以我在一个网站上找到了一个游戏,我试图用一些功能来扩展它,但我遇到了一些问题。
首先,我得到了一个表面视图、线程和一个游戏结束活动。游戏结束后,我重定向到游戏结束活动:
synchronized (holder){
Intent gameOverScreen = new Intent();
gameOverScreen.setClassName("packagename", "packagename.GameOverScreen");
((Activity) context).startActivity(gameOverScreen);
在游戏结束活动中,我有一个“重试”按钮,它重定向回游戏视图,但随后弹出一个错误并要求我强制关闭我的应用程序,当我按下强制关闭按钮时,它会重定向,因为代码如下所示:
public void onClick(View v){
Intent i = new Intent();
i.setClassName("packagename", "packagename.GameView");
startActivity(i);
finish();
}
所以我的问题是如何避免这个错误,因为代码“有效”,但我需要按下弹出的强制关闭按钮。我是 Java 和游戏开发的新手。
提前致谢!
编辑日志猫:
04-20 20:58:02.022: D/Main(1484): Stopping...
04-20 20:58:08.843: D/AndroidRuntime(1484): Shutting down VM
04-20 20:58:08.843: W/dalvikvm(1484): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
04-20 20:58:08.843: E/AndroidRuntime(1484): Uncaught handler: thread main exiting due to uncaught exception
04-20 20:58:08.888: E/AndroidRuntime(1484): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.edu4java.android.killthemall/com.edu4java.android.killthemall.GameView}; have you declared this activity in your AndroidManifest.xml?
04-20 20:58:08.888: E/AndroidRuntime(1484): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
04-20 20:58:08.888: E/AndroidRuntime(1484): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
04-20 20:58:08.888: E/AndroidRuntime(1484): at android.app.Activity.startActivityForResult(Activity.java:2749)
04-20 20:58:08.888: E/AndroidRuntime(1484): at android.app.Activity.startActivity(Activity.java:2855)
04-20 20:58:08.888: E/AndroidRuntime(1484): at com.edu4java.android.killthemall.GameOverScreen$1.onClick(GameOverScreen.java:19)
04-20 20:58:08.888: E/AndroidRuntime(1484): at android.view.View.performClick(View.java:2364)
04-20 20:58:08.888: E/AndroidRuntime(1484): at android.view.View.onTouchEvent(View.java:4179)
04-20 20:58:08.888: E/AndroidRuntime(1484): at android.widget.TextView.onTouchEvent(TextView.java:6541)
04-20 20:58:08.888: E/AndroidRuntime(1484): at android.view.View.dispatchTouchEvent(View.java:3709)
04-20 20:58:08.888: E/AndroidRuntime(1484): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-20 20:58:08.888: E/AndroidRuntime(1484): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-20 20:58:08.888: E/AndroidRuntime(1484): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-20 20:58:08.888: E/AndroidRuntime(1484): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-20 20:58:08.888: E/AndroidRuntime(1484): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
04-20 20:58:08.888: E/AndroidRuntime(1484): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
04-20 20:58:08.888: E/AndroidRuntime(1484): at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
04-20 20:58:08.888: E/AndroidRuntime(1484): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
04-20 20:58:08.888: E/AndroidRuntime(1484): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
04-20 20:58:08.888: E/AndroidRuntime(1484): at android.os.Handler.dispatchMessage(Handler.java:99)
04-20 20:58:08.888: E/AndroidRuntime(1484): at android.os.Looper.loop(Looper.java:123)
04-20 20:58:08.888: E/AndroidRuntime(1484): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-20 20:58:08.888: E/AndroidRuntime(1484): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 20:58:08.888: E/AndroidRuntime(1484): at java.lang.reflect.Method.invoke(Method.java:521)
04-20 20:58:08.888: E/AndroidRuntime(1484): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-20 20:58:08.888: E/AndroidRuntime(1484): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-20 20:58:08.888: E/AndroidRuntime(1484): at dalvik.system.NativeStart.main(Native Method)
04-20 20:58:08.903: I/dalvikvm(1484): threadid=7: reacting to signal 3
04-20 20:58:08.903: E/dalvikvm(1484): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
04-20 20:58:16.883: I/Process(1484): Sending signal. PID: 1484 SIG: 9