完整报错信息
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.app01, PID: 13901
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.app01/com.example.app01.RegisterActivity}; have you declared this activity in your AndroidManifest.xml?
解决方案
根据日志信息不难发现问题的所在,就是我们需要将存在的activity在清单文件AndroidManifest.xml中进行配置才可以成为真正有效的活动单元,否则无法执行启动。
配置Activity语法:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.app01">
<application>
<activity android:name=".activity的类名" />
</application>
</manifest>
手动如下:
自动配置小技巧:
鼠标单击activity使光标在上面闪烁,然后使用快捷键 Alt+Enter 选择 Add activity to manifest 即可实现将当前activity自动配置到清单文件AndroidManifest.xml中,非常方便!
END.