Android registerOnSharedPreferenceChangeListener () causa falha em um modo de exibição personalizado

Sempre que tento adicionar esta linha, ele trava meu aplicativo. Não estou colocando no lugar certo?

    preferences.registerOnSharedPreferenceChangeListener(myActivity.this);

Aqui está minha turma

class Simulation extends View {

    // I declare my program variables here
    public Simulation(Context context) {
        super(context);
        // get the preferences
        SharedPreferences preferences = PreferenceManager
                .getDefaultSharedPreferences(context);
        preferences
                .registerOnSharedPreferenceChangeListener(myActivity.this);
        String storedPreference = preferences.getString("nPref", "0");
    }

    public void onSharedPreferenceChanged(
            SharedPreferences sharedPreferences, String key) {
        Log.i(TAG, "preferences changed!");
    }
}

Obrigado

questionAnswers(2)

yourAnswerToTheQuestion