I'm trying to implement a PreferenceActivity in my app, following the accepted answer in this question
I get the above exception
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
<?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>
The activity launching code
@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>
and use it:
Intent i = new Intent("com.iphonik.chameleon.AppPreferenceActivity");