本文介绍了找不到明确的活动类别.您是否在AndroidManifest.xml中声明了此活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试按照
我收到上述例外情况
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.iphonik.chameleon/com.iphonik.AppPreferenceActivity}; have you declared this activity in your AndroidManifest.xml?
AndroidManifest.xml
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.iphonik.chameleon">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.NoTitleBar">
<activity android:name=".MainMenu">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Movies" />
<activity android:name=".SettingsActivity" />
<activity android:name=".InfoActivity" />
<receiver
android:name=".AppBroadcastReciever"
android:enabled="true"
android:exported="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<activity android:name=".Info2Activity" />
<activity android:name=".ItemDetailActivity" />
<activity android:name=".TVActivity" />
<activity android:name="com.iphonik.chameleon.AppPreferenceActivity"
android:label="Preferences">
</activity>
</application>
</manifest>
活动启动代码
@Override
public boolean onOptionsItemSelected(MenuItem item){
switch(item.getItemId()) {
case R.id.preferences:
Intent intent = new Intent();
intent.setClassName(this, "com.iphonik.AppPreferenceActivity");
startActivity(intent);
return true;
}
return super.onOptionsItemSelected(item);
}
推荐答案
声明您的活动,如下所示:
declare your activity like this:
<activity
android:name=".AppPreferenceActivity"
android:label="Preferences" >
<intent-filter>
<action android:name="com.iphonik.chameleon.AppPreferenceActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
并使用它:
Intent i = new Intent("com.iphonik.chameleon.AppPreferenceActivity");
这篇关于找不到明确的活动类别.您是否在AndroidManifest.xml中声明了此活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!