To clear things up, I want my SettingsActivity.class to restart. Everything works except finish(), which doesn't seem to work at all. My code creates a new SettingsActivity.class but doesn't destroy the old one.
private SharedPreferences.OnSharedPreferenceChangeListener listener1 = new SharedPreferences.OnSharedPreferenceChangeListener() {
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
if (key.equals("tema1")) {
finish();
startActivity(getIntent());
}
if (key.equals("tema2")) {
finish();
startActivity(getIntent());
}
if (key.equals("notification")) {
recreate();
}
The problem is therefore that finish() does not work. It simply doesn't destroy the activity. As I said, everything else works.
Edit Finish() still doesn't work and I'd like an answer to that, but I managed to make a workaround by using the intentflag "clear top" for the startActivity intent. Achieves the same effect as I wanted, without even using finish().