You're bad. The architecture is bad. The solutions are bad. I can not look at your code and your vain attempts to invent another bike. I'll just show you how I did when I wrote my one program for Android. This scheme should give an approximate idea of how to recover after the screen turns or closes. I want to note that the preferences object is filled with values completely in other places, and not in the call-back methods. For example, I have a special activit in which I expose a bunch of settings as the size / color of the brush shape.
@Override protected void onCreate(Bundle in) { super.onCreate(in); if (in != null) { // этот блок выполняется когда произошёл поворот Activity. // Восстанавливаем из Bundle }else { // выполняется когда запущено первый раз. считывание из Preferences } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); application.saveStack(undoStack); application.saveBitmap(editableBitmap); writePaintBrushToBundle(paintBrush, outState); writePaintTextToBundle(paintText, outState); } public static void writePaintTextToBundle(Paint p, Bundle bundle) { bundle.putInt(PAINT_TEXT_COLOR_KEY, p.getColor()); bundle.putFloat(PAINT_TEXT_SIZE_KEY, p.getTextSize()); } public static Paint readPaintTextFromBundle(Bundle bundle) { Paint p = new Paint(); int color = bundle.getInt(PAINT_TEXT_COLOR_KEY, DEFAULT_PAINT_TEXT_COLOR); float textSize = bundle.getFloat(PAINT_TEXT_SIZE_KEY, DEFAULT_PAINT_TEXT_SIZE); p.setColor(color); p.setTextSize(textSize); return p; }
This should roughly clarify how you should work with the Bundle and Preferences. If it is still not clear - I can post the full code of my activation. It is large (it was written a long time ago, along with anti-patterns), but I can point out methods that should be noted.