0

所以我正在尝试使用 Intents 切换视图,我之前已经能够让它工作,但现在它只是一直关闭,这也是通过菜单按钮,这是我的菜单代码:

public boolean onCreateOptionsMenu(android.view.Menu menu) {
    super.onCreateOptionsMenu(menu);
    MenuInflater blowUp = getMenuInflater();
    blowUp.inflate(R.menu.menu, menu);
    return true;
}
public boolean onOptionsItemSelected(MenuItem item){
    switch(item.getItemId()){
    case R.id.stats:
            Intent i = new Intent("com.mittereder.rockpaper.STATS");
            startActivity(i);
        break;
    }
    return false;
}

这是包含该项目的我的菜单:

    <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:id="@+id/stats"
        android:alphabeticShortcut="s"
        android:title="Stats"/>

</menu>

那么这是我的清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mittereder.rockpaper"
    android:versionCode="2"
    android:versionName="1.2" >

    <uses-sdk android:minSdkVersion="8" />

    <application
        android:icon="@drawable/stop"
        android:label="@string/app_name" >
        <activity
            android:name=".start"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".stats"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.mittereder.rockpaper.STATS" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>

</manifest>

我一遍又一遍地检查我的代码,但我不知道我错过了什么。

日志猫:

08-09 11:51:11.471: E/AndroidRuntime(13384): FATAL EXCEPTION: main
08-09 11:51:11.471: E/AndroidRuntime(13384): android.app.SuperNotCalledException: Activity {com.mittereder.rockpaper/com.mittereder.rockpaper.start} did not call through to super.onPause()
08-09 11:51:11.471: E/AndroidRuntime(13384):    at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3103)
08-09 11:51:11.471: E/AndroidRuntime(13384):    at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3062)
08-09 11:51:11.471: E/AndroidRuntime(13384):    at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3035)
08-09 11:51:11.471: E/AndroidRuntime(13384):    at android.app.ActivityThread.access$800(ActivityThread.java:139)
08-09 11:51:11.471: E/AndroidRuntime(13384):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1268)
08-09 11:51:11.471: E/AndroidRuntime(13384):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-09 11:51:11.471: E/AndroidRuntime(13384):    at android.os.Looper.loop(Looper.java:154)
08-09 11:51:11.471: E/AndroidRuntime(13384):    at android.app.ActivityThread.main(ActivityThread.java:4945)
08-09 11:51:11.471: E/AndroidRuntime(13384):    at java.lang.reflect.Method.invokeNative(Native Method)
08-09 11:51:11.471: E/AndroidRuntime(13384):    at java.lang.reflect.Method.invoke(Method.java:511)
08-09 11:51:11.471: E/AndroidRuntime(13384):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-09 11:51:11.471: E/AndroidRuntime(13384):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-09 11:51:11.471: E/AndroidRuntime(13384):    at dalvik.system.NativeStart.main(Native Method)
4

1 回答 1

2

看起来您的 Start Activity 覆盖了 onPause 并且不调用超类。在启动 stat 活动之前,在 start 活动上调用 onPause。

于 2012-08-09T15:57:06.810 回答