I am using the preferenceActivy class to manage my preferences. But I need to close the whole preferences from a fragment. Source code is cut to a minimal example
public class VPNPreferences extends PreferenceActivity {
public boolean onOptionsItemSelected(MenuItem item) {
finish(); // This should close fragment + Preferences list
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.vpnpreferences_menu, menu);
return super.onCreateOptionsMenu(menu);
}
}
I use the new 3.2+ API which display as two column on tables and as sperate Activities on mobile phone. The menu icon is visible on both the list and the Activity with the fragment.
When the button button is pressed the activy should close and if the activity is the fragment was called from the Settings list that setting list should close too. Unfortunately finish() only closes the current fragment Activity.