I have placed this into my PreferencesActivity
PreferencesActivity:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
Preference preferences = findPreference("key");
preferences.setIntent(new Intent(getApplicationContext(), RegisterActivity.class));
}
preferences.xml
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="Preferences">
<Preference android:key="Pssword" android:title="Set SMS Notification Password"></Preference>
</PreferenceCategory>
</PreferenceScreen>
The moment i try to enter the preferences screen it crashes.
You have a NullPointException because your
keypreference doesn’t exist.Replace your line
Preference preferences = findPreference("key");withPreference preferences = findPreference("Pssword");This should resolve your issue.