菜单按钮强制关闭android?

时间:2011-04-29 21:45:39

标签: android eclipse google-maps android-maps

我有和应用程序在打开菜单按钮时工作正常并转到设置然后按下后退按钮但是当我将Google Maps API添加到我的应用程序时后退按钮强制关闭应用程序。有没有其他人有同样的问题?如果是这样,你是如何解决它的?或者有人知道如何解决这个问题吗?

修改

后退按钮上的日志cat错误强制关闭

04-29 16:02:13.155: ERROR/AndroidRuntime(16828): FATAL EXCEPTION: main
04-29 16:02:13.155: ERROR/AndroidRuntime(16828): java.lang.RuntimeException: Unable to            resume activity {www.Freshapp.com.Thumper.html/www.Freshapp.com.Thumper.html.Thumper}: java.lang.NullPointerException
04-29 16:02:13.155: ERROR/AndroidRuntime(16828):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3128)
04-29 16:02:13.155: ERROR/AndroidRuntime(16828):     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3143)
04-29 16:02:13.155: ERROR/AndroidRuntime(16828):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2059)
04-29 16:02:13.155: ERROR/AndroidRuntime(16828):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-29 16:02:13.155: ERROR/AndroidRuntime(16828):     at android.os.Looper.loop(Looper.java:123)
04-29 16:02:13.155: ERROR/AndroidRuntime(16828):     at android.app.ActivityThread.main(ActivityThread.java:4627)
04-29 16:02:13.155: ERROR/AndroidRuntime(16828):     at java.lang.reflect.Method.invokeNative(Native Method)
04-29 16:02:13.155: ERROR/AndroidRuntime(16828):     at java.lang.reflect.Method.invoke(Method.java:521)
04-29 16:02:13.155: ERROR/AndroidRuntime(16828):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
04-29 16:02:13.155: ERROR/AndroidRuntime(16828):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
04-29 16:02:13.155: ERROR/AndroidRuntime(16828):     at dalvik.system.NativeStart.main(Native Method)
04-29 16:02:13.155: ERROR/AndroidRuntime(16828): Caused by: java.lang.NullPointerException
04-29 16:02:13.155: ERROR/AndroidRuntime(16828):     at com.google.android.maps.MapActivity.onResume(MapActivity.java:431)
04-29 16:02:13.155: ERROR/AndroidRuntime(16828):     at www.Freshapp.com.Thumper.html.Thumper.onResume(Thumper.java:181)
04-29 16:02:13.155: ERROR/AndroidRuntime(16828):     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)
04-29 16:02:13.155: ERROR/AndroidRuntime(16828):     at android.app.Activity.performResume(Activity.java:3823)
04-29 16:02:13.155: ERROR/AndroidRuntime(16828):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3118)

修改2

我拿出了我的地图视图和地图视图所在的滑动抽屉,以及与地图和应用程序无关的内容。

-Thanks

1 个答案:

答案 0 :(得分:0)

我想通了,我只需要在我的设置中添加一个后退按钮功能。现在很棒

public boolean onKeyDown(int keyCode, KeyEvent event) {
    Log.d(null,"In on Key Down");
    if (keyCode == KeyEvent.KEYCODE_BACK) {
  Intent intent=new Intent(Settings.this,Thumper.class);
  startActivity(intent);
        return true;
    }

    return false;
}