单击关于按钮关闭应用程序

时间:2017-06-04 16:48:14

标签: android activitynotfoundexception

06-04 12:34:07.871 3697-3697 / com.example.halls.basicrecipes E / AndroidRuntime:FATAL EXCEPTION:main                                                                               处理:com.example.halls.basicrecipes,PID:3697                                                                               android.content.ActivityNotFoundException:无法找到显式活动类{com.example.halls.basicrecipes / com.example.halls.basicrecipes.About};你有没有在AndroidManifest.xml中声明这个活动?                                                                                   在android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1805)                                                                                   在android.app.Instrumentation.execStartActivity(Instrumentation.java:1523)                                                                                   在android.app.Activity.startActivityForResult(Activity.java:4224)                                                                                   在android.app.Activity.startActivityForResult(Activity.java:4183)                                                                                   在android.app.Activity.startActivity(Activity.java:4507)                                                                                   在android.app.Activity.startActivity(Activity.java:4475)                                                                                   在com.example.halls.basicrecipes.MainMenu.onClick(MainMenu.java:22)                                                                                   在android.view.View.performClick(View.java:5610)                                                                                   在android.view.View $ PerformClick.run(View.java:22265)                                                                                   在android.os.Handler.handleCallback(Handler.java:751)                                                                                   在android.os.Handler.dispatchMessage(Handler.java:95)                                                                                   在android.os.Looper.loop(Looper.java:154)                                                                                   在android.app.ActivityThread.main(ActivityThread.java:6077)                                                                                   at java.lang.reflect.Method.invoke(Native Method)                                                                                   在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:865)                                                                                   在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

enter code here

这是我的代码

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.halls.basicrecipes">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainMenu">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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


</manifest>

1 个答案:

答案 0 :(得分:0)

项目中的每个 Person person = new Person.Builder("myName").address("myAddress").phone("my phone").build(); 都必须在Activity中声明。

因此,您必须在Manifest文件中声明关于activity,如下所示:

AndroidManifest