活动回到surfaceview“工作”并出现错误

时间:2012-04-20 20:23:26

标签: android android-intent surfaceview

所以我在网站上发现了一款​​游戏,我试图用一些功能扩展它,我遇到了一些问题。

首先我得到了一个surfaceview,线程和gameover活动。 当游戏结束时,我会重定向到游戏结束活动:

    synchronized (holder){
                    Intent gameOverScreen = new Intent();
                    gameOverScreen.setClassName("packagename", "packagename.GameOverScreen");
                    ((Activity) context).startActivity(gameOverScreen);

在gameover活动中,我有一个“再试一次”按钮,重定向回游戏视图,但随后出现错误并要求我强制关闭我的应用程序,当我按下强制关闭按钮时,它重定向,因为代码如下游戏视图:

            public void onClick(View v){
            Intent i = new Intent();
            i.setClassName("packagename", "packagename.GameView");
            startActivity(i);
            finish();
        }

所以我的问题是如何避免这个错误,因为代码“工作”但我需要按下弹出的强制关闭按钮。我是java和游戏开发的新手。

提前致谢!

编辑logcat:

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

0 个答案:

没有答案