Android Start Preference Activity Intent results in Exception
<p>i have a problem, i want to run an activity which handles a preference dialog</p>

<pre><code>Intent i= new Intent(getBaseContext(), PreferencesActivity.class);
            startActivity(i);
</code></pre>

<p>when i run the app i only get an nullpointerexcepltion when the activity should start. what is wrong?</p>

<p>PreferencesActivity looks this way: </p>

<pre><code>import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.Preference.OnPreferenceClickListener;
import android.widget.Toast;

public class PreferencesActivity extends PreferenceActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.layout.preferences);
        // Get the custom preference
        Preference customPref = (Preference) findPreference("customPref");
        customPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

             public boolean onPreferenceClick(Preference preference) {
                 Toast.makeText(getBaseContext(),
                     "The custom preference has been clicked",
                     Toast.LENGTH_LONG).show();
                 SharedPreferences customSharedPreference = getSharedPreferences(
                     "myCustomSharedPrefs", Activity.MODE_PRIVATE);
                 SharedPreferences.Editor editor = customSharedPreference.edit();
                 editor.putString("myCustomPref","The preference has been clicked");
                 editor.commit();
                 return true;
            }
        });
    }
}
</code></pre>
