单击菜单时强制关闭

时间:2014-06-28 19:53:09

标签: android

我的菜单有问题。 这项工作之前,但现在当我点击AVD菜单时,设备将强制关闭。 在我的应用程序中一些活动工程菜单但有些人不行。例如,这项活动不起作用,我可以找到错误。 这是我在java上的代码:

    @Override
public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.alert_setting, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    switch (item.getItemId()){

    case R.id.mnuAlertExit:
        finish();
        System.exit(0);

    break;

    case R.id.mnuAlertMainMenu:
        startActivity(new Intent(AlertSettingActivity.this,MainActivity.class));
        finish();

    break;
    case R.id.mnuAlertSettings:
startActivity(new  Intent(AlertSettingActivity.this,SlaveCommand.class));
        finish();

    break;


    }

这是我的菜单代码:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.gpsportalsms.AlertSettingActivity" >
<group android:id="@+id/group1">
<item android:id="@+id/mnuAlertMainMenu" android:title="منوی اصلی"></item>
<item android:id="@+id/mnuAlertSettings" android:title="تنظیم اخطارها"></item>
<item android:id="@+id/mnuAlertContact" android:title="ارسال نظرات پیشنهادات"> </item>
<item android:id="@+id/mnuAlertExit" android:title="خروج"></item>


</group>

</menu>

这是我的logcat

06-28 19:36:22.812: D/libEGL(1976): loaded /system/lib/egl/libGLESv1_CM_genymotion.so
06-28 19:36:22.812: D/libEGL(1976): loaded /system/lib/egl/libGLESv2_genymotion.so
06-28 19:36:22.948: W/EGL_genymotion(1976): eglSurfaceAttrib not implemented
06-28 19:36:22.952: E/OpenGLRenderer(1976): Getting MAX_TEXTURE_SIZE from GradienCache
06-28 19:36:22.952: E/OpenGLRenderer(1976): MAX_TEXTURE_SIZE: 4096
06-28 19:36:22.992: E/OpenGLRenderer(1976): Getting MAX_TEXTURE_SIZE from  Caches::initConstraints()
06-28 19:36:22.996: E/OpenGLRenderer(1976): MAX_TEXTURE_SIZE: 4096
06-28 19:36:22.996: D/OpenGLRenderer(1976): Enabling debug mode 0
06-28 19:36:26.144: E/InputEventSender(1976): Exception dispatching finished signal.
06-28 19:36:26.144: E/MessageQueue-JNI(1976): Exception in MessageQueue callback: handleReceiveCallback
06-28 19:36:26.144: E/MessageQueue-JNI(1976): java.lang.NullPointerException
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.support.v7.app.ActionBarImplICS.getThemedContext(ActionBarImplICS.java:302)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.support.v7.app.ActionBarImplJB.getThemedContext(ActionBarImplJB.java:20)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.support.v7.app.ActionBarActivityDelegate.getActionBarThemedContext(ActionBarActivityDelegate.java:208)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.support.v7.app.ActionBarActivityDelegate.getMenuInflater(ActionBarActivityDelegate.    06-28 19:36:26.144: E/MessageQueue-JNI(1976):     at android.support.v7.app.ActionBarActivity.getMenuInflater(ActionBarActivity.java:71)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at com.example.gpsportalsms.SlaveCommand.onCreateOptionsMenu(SlaveCommand.java:2002)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.app.Activity.onCreatePanelMenu(Activity.java:2538)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:224)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.support.v7.app.ActionBarActivity.superOnCreatePanelMenu(ActionBarActivity.java:232)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.support.v7.app.ActionBarActivityDelegateICS.onCreatePanelMenu(ActionBarActivityDelegateICS.java:146)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.support.v7.app.ActionBarActivity.onCreatePanelMenu(ActionBarActivity.java:199)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.onCreatePanelMenu(ActionBarActivityDelegateICS.java:293)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:436)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel(PhoneWindow.java:820)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at  com.android.internal.policy.impl.PhoneWindow.onKeyDown(PhoneWindow.java:1568)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1969)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:3852)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3826)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3449)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3418)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3525)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3426)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3582)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3449)
 06-28 19:36:26.144: E/MessageQueue-JNI(1976):  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3418)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3426)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3449)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3418)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3558)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at  android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:3718)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2010)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1704)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1695)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:1987)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.os.MessageQueue.nativePollOnce(Native Method)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.os.MessageQueue.next(MessageQueue.java:138)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.os.Looper.loop(Looper.java:123)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at android.app.ActivityThread.main(ActivityThread.java:5017)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at java.lang.reflect.Method.invokeNative(Native Method)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at java.lang.reflect.Method.invoke(Method.java:515)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
06-28 19:36:26.144: E/MessageQueue-JNI(1976):   at dalvik.system.NativeStart.main(Native Method)
06-28 19:36:26.144: D/AndroidRuntime(1976): Shutting down VM
06-28 19:36:26.144: W/dalvikvm(1976): threadid=1: thread exiting with uncaught exception (group=0xa4cfab20)
 06-28 19:36:26.148: E/AndroidRuntime(1976): FATAL EXCEPTION: main
06-28 19:36:26.148: E/AndroidRuntime(1976): Process: com.example.gpsportalsms, PID: 1976
06-28 19:36:26.148: E/AndroidRuntime(1976): java.lang.NullPointerException
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.support.v7.app.ActionBarImplICS.getThemedContext(ActionBarImplICS.java:302)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.support.v7.app.ActionBarImplJB.getThemedContext(ActionBarImplJB.java:20)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.support.v7.app.ActionBarActivityDelegate.getActionBarThemedContext(ActionBarActivityDelegate.java:208)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.support.v7.app.ActionBarActivityDelegate.getMenuInflater(ActionBarActivityDelegate.java:98)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.support.v7.app.ActionBarActivity.getMenuInflater(ActionBarActivity.java:71)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at com.example.gpsportalsms.SlaveCommand.onCreateOptionsMenu(SlaveCommand.java:2002)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.app.Activity.onCreatePanelMenu(Activity.java:2538)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at  android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:224)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.support.v7.app.ActionBarActivity.superOnCreatePanelMenu(ActionBarActivity.java:232)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.support.v7.app.ActionBarActivityDelegateICS.onCreatePanelMenu(ActionBarActivityDelegateICS.java:146)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.support.v7.app.ActionBarActivity.onCreatePanelMenu(ActionBarActivity.java:199)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.onCreatePanelMenu(ActionBarActivityDelegateICS.java:293)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:436)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel(PhoneWindow.java:820)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at com.android.internal.policy.impl.PhoneWindow.onKeyDown(PhoneWindow.java:1568)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1969)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:3852)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3826)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3449)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3418)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3525)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3426)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3582)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3449)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3418)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3426)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3449)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3418)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3558)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:3718)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2010)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1704)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1695)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:1987)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.os.MessageQueue.nativePollOnce(Native Method)
 06-28 19:36:26.148: E/AndroidRuntime(1976):    at android.os.MessageQueue.next(MessageQueue.java:138)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.os.Looper.loop(Looper.java:123)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at android.app.ActivityThread.main(ActivityThread.java:5017)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at java.lang.reflect.Method.invokeNative(Native Method)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at java.lang.reflect.Method.invoke(Method.java:515)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
06-28 19:36:26.148: E/AndroidRuntime(1976):     at dalvik.system.NativeStart.main(Native Method)
06-28 19:36:28.044: I/Process(1976): Sending signal. PID: 1976 SIG: 9

thnaks all

0 个答案:

没有答案