0

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.

Ron
  • 24,175
  • 8
  • 56
  • 97
dythe
  • 840
  • 5
  • 21
  • 45

2 Answers2

3

Your preference is called Pssword, not key.

zmbq
  • 38,013
  • 14
  • 101
  • 171
1

You have a NullPointException because your key preference doesn't exist.

Replace your line Preference preferences = findPreference("key"); with Preference preferences = findPreference("Pssword");

This should resolve your issue.

yugidroid
  • 6,640
  • 2
  • 30
  • 45