我在保存一些数据后一直试图回到某个活动。保存所有作品找到。没有错误,所有流都关闭。然后我尝试回到MainMenu活动,似乎没有工作。还有一些我不知道它是否会影响它,但是如果我在课堂上创建了一些TextFields,我是否需要在进行新活动之前删除它们?
(“com.sureclean.versionioo.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>
logcat的:
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)
答案 0 :(得分:1)
如果此活动存在于清单中定义的包中...您可以编写android:name =“。MainMenu”
但如果包名是其他的,那么写全名
机器人:名称= “yourpackagename.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));
答案 1 :(得分:0)
测试一下:
你的宣言:
<activity
android:name=".MainMenu"
android:label="@string/title_activity_main" >
</activity>
您的代码:
public void onClick(View v) {
startActivity(new Intent(this, MainMenu.class));
}
答案 2 :(得分:0)
再次检查错误。错误的是你得到了包
“com。确定 .versionioo.MAIN”
并且您已将活动定义为
“融为一体的 sureclean 强> .versionioo.MainMenu”
表示包名称中存在错误。检查包名称。
答案 3 :(得分:0)
使用上面提到的清单尝试此操作:
Intent intMainMenu=new Intent(this, MainMenu.class);
intMainMenu.setAction("com.sureclean.versionioo.MainMenu");
startActivity(intMainMenu);
答案 4 :(得分:0)
试试这个
Intent intent = new Intent();
intent.setClassName("com.sureclean.versionioo", "com.sureclean.versionioo.MainMenu");
startActivity(intent);
我遇到同样的问题并且此代码有效