Android 异常解决 content.ActivityNotFoundException: Unable to find explicit activity class

来源:互联网 发布:php防止sql注入代码 编辑:程序博客网 时间:2024/04/25 21:01

出错提示:

    android.content.ActivityNotFoundException: Unable to find explicit activity class

1. 刚开始发现这个问题,觉得是代码有问题,但实际上并不是。

CODE snipet

 @Override        public void onClick(View v) {            Intent intent = CrimeActivity.newIntent(getActivity(), mCrime.getId());            startActivity(intent);        }

2. Solution

依据提示”have you declared this activity in your AndroidManifest.xml?”,可以明白大概方向,google一处1,基本上就知道在AndroidManifest.xml中少了部分,只是我不太明白为什么非要在这里注册呢?

<?xml version="1.0" encoding="utf-8"?><manifest package="com.york.android.criminalintent"          xmlns:android="http://schemas.android.com/apk/res/android">    <application        android:allowBackup="true"        android:icon="@mipmap/ic_launcher"        android:label="@string/app_name"        android:supportsRtl="true"        android:theme="@style/AppTheme">        <activity android:name=".CrimeActivity"></activity>        <activity android:name=".CrimeListActivity">            <intent-filter>                <action android:name="android.intent.action.MAIN"/>                <category android:name="android.intent.category.LAUNCHER"/>            </intent-filter>        </activity>    </application></manifest>

后记

From this code, I learned lately that this code let the OS can start it.

…to the manifest so that the OS can start it.


0 0
原创粉丝点击