PreferenceActivity Nullpoint Error

by Radzell » Thu, 19 Nov 2009 16:08:58 GMT


Sponsored Links
  keep getting a nullpoint error from my preferenceactivity i have no
idea whats wrong. I debug and the saveInstancestate is coming in null
for some reason, but it may be something else.

public class SettingsFrontEnd extends PreferenceActivity {
public static final String NO_SELECTION = "0&#8243";

public static final String PASSWORD_KEY = "PASSWORDKEY";
public static final String SELECTED_TARGET_KEY =
"SelectedTargetKey";
public final String QUICK_CONTACT_KEY = "QUICK_CONTACT_KEY";

private android.content.SharedPreferences.Editor editor;
private HelpiDB mDbHelper;

private EditTextPreference passwordPreference;

private SharedPreferences pref;

private CheckBoxPreference quickcontactPreference;
private ListPreference targets;

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);

return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.settings_menu:

break;
case R.id.contact_menu:
if (targets.getValue().equals(NO_SELECTION)) {
Toast.makeText(this, "Choose a Main COntact",
Toast.LENGTH_LONG).show
();
} else {
Intent myIntent = new Intent(SettingsFrontEnd.this,
ContactFrontEnd.class);
startActivityForResult(myIntent, 0);
}
break;
case R.id.map_menu:
if (targets.getValue().equals(NO_SELECTION)) {
Toast.makeText(this, "Choose a Main COntact",
Toast.LENGTH_LONG).show
();
} else {
Intent myIntent = new Intent(SettingsFrontEnd.this,
ContactFrontEnd.class);
startActivityForResult(myIntent, 0);
}
break;
case R.id.insert_menu:
if (targets.getValue().equals(NO_SELECTION)) {
Toast.makeText(this, "Choose a Main COntact",
Toast.LENGTH_LONG).show
();
} else {
Intent myIntent = new Intent(SettingsFrontEnd.this,
InsertFrontEnd.class);
startActivityForResult(myIntent, 0);
}
break;

default:
// put your code here
}
return false;
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setPreferenceScreen(createPreferenceHierarchy());

pref
.registerOnSharedPreferenceChangeListener(new
SharedPreferences.OnSharedPreferenceChangeListener() {

@Override
public void onSharedPreferenceChanged(SharedPreferences
sharedPreferences,
String key) {
if (key.equals(SELECTED_TARGET_KEY)) {
editor = pref.edit();
editor.putString(key, targets.getValue());
}
if (key.equals(PASSWORD_KEY)) {
editor = pref.edit();
editor.putString(key, passwordPreference.getText());
}
if (key.equals(QUICK_CONTACT_KEY)) {
editor