0

保存一些数据后,我一直在尝试返回活动。保存所有作品找到。那里没有错误,所有流都已关闭。然后我尝试回到 MainMenu 活动,它似乎不起作用。还有一些我不知道它是否会影响它的东西,但是如果我在课堂上创建了一些 TextFields,我是否需要在进行新活动之前删除它们?

("com.sureclean.versionio.settings") 中新活动的代码:

public void onClick(View v) {
        //Saving data code in here
    startActivity(new Intent("com.sureclean.versionioo.MainMenu"));
}

整个清单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sureclean.versionioo"
android:versionCode="1"
android:versionName="1.0" >

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

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".Splash"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".MainMenu"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="com.sureclean.versionioo.MainMenu" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name=".checklist"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name=".checklist" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name=".settings"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="com.sureclean.versionioo.settings" />

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

日志猫:

09-12 15:58:03.949: E/AndroidRuntime(1079): FATAL EXCEPTION: main
09-12 15:58:03.949: E/AndroidRuntime(1079): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.surehere.versionioo.MAIN }
09-12 15:58:03.949: E/AndroidRuntime(1079):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512)
09-12 15:58:03.949: E/AndroidRuntime(1079):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
09-12 15:58:03.949: E/AndroidRuntime(1079):     at android.app.Activity.startActivityForResult(Activity.java:3190)
09-12 15:58:03.949: E/AndroidRuntime(1079):     at android.app.Activity.startActivity(Activity.java:3297)
09-12 15:58:03.949: E/AndroidRuntime(1079):     at com.sureclean.versionioo.settings$1.onClick(settings.java:54)
09-12 15:58:03.949: E/AndroidRuntime(1079):     at android.view.View.performClick(View.java:3511)
09-12 15:58:03.949: E/AndroidRuntime(1079):     at android.view.View$PerformClick.run(View.java:14105)
09-12 15:58:03.949: E/AndroidRuntime(1079):     at android.os.Handler.handleCallback(Handler.java:605)
09-12 15:58:03.949: E/AndroidRuntime(1079):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-12 15:58:03.949: E/AndroidRuntime(1079):     at android.os.Looper.loop(Looper.java:137)
09-12 15:58:03.949: E/AndroidRuntime(1079):     at android.app.ActivityThread.main(ActivityThread.java:4424)
09-12 15:58:03.949: E/AndroidRuntime(1079):     at java.lang.reflect.Method.invokeNative(Native Method)
09-12 15:58:03.949: E/AndroidRuntime(1079):     at java.lang.reflect.Method.invoke(Method.java:511)
09-12 15:58:03.949: E/AndroidRuntime(1079):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-12 15:58:03.949: E/AndroidRuntime(1079):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-12 15:58:03.949: E/AndroidRuntime(1079):     at dalvik.system.NativeStart.main(Native Method)
4

5 回答 5

1

如果清单中定义的包中存在此活动...您可以编写 android:name=".MainMenu"

但如果包名是其他人所以写全名

android:name="你的包名.MainMenu"

使用此清单一次

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.sureclean.versionioo"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".Splash"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MainMenu"
            android:label="@string/title_activity_main" >
        </activity>
        <activity
            android:name=".checklist"
            android:label="@string/title_activity_main" >
        </activity>
        <activity
            android:name=".settings"
            android:label="@string/title_activity_main" >
        </activity>
    </application>

并在按钮上单击

startActivity(new Intent(settings.this,MainMenu.class));
于 2012-09-12T04:15:34.880 回答
0

测试这个:

您的清单:

<activity
    android:name=".MainMenu"
    android:label="@string/title_activity_main" >
</activity>

你的代码:

public void onClick(View v) {
    startActivity(new Intent(this, MainMenu.class));
}
于 2012-09-12T04:14:35.417 回答
0

再次检查您的错误。错误地你得到了包裹

com.surehere.versionioo.MAIN

并且您已经定义了对您的活动的操作是

com.sureclean.versionioo.MainMenu

表示包名有问题。检查一次包名。

于 2012-09-12T04:44:34.840 回答
0

试试上面提到的清单:

    Intent intMainMenu=new Intent(this, MainMenu.class);
    intMainMenu.setAction("com.sureclean.versionioo.MainMenu");
    startActivity(intMainMenu);
于 2012-09-12T04:52:26.083 回答
0

试试这个

Intent intent = new Intent();
intent.setClassName("com.sureclean.versionioo", "com.sureclean.versionioo.MainMenu");
            startActivity(intent);

我遇到了同样的问题,这段代码有效

于 2014-03-18T09:05:54.433 回答