@Override protected void onStart() { final GameBoard boardView = (GameBoard) this.findViewById(R.id.gameBoard); SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE); this.level = prefs.getInt("level", 0); String mapJson = prefs.getString("map", null); if (mapJson == null) { waitForNext = true; } else { this.game.initGame(mapJson); String howdyPosition = prefs.getString("howdy", null); if (howdyPosition != null) { this.game.setHowdyPosition(howdyPosition); } Toast.makeText(this, this.level + "", Toast.LENGTH_SHORT).show(); } String allDoneLevelsString = prefs.getString("doneLevels", null); if (allDoneLevelsString != null) { allDoneLevels = new ArrayList<String>(Arrays.asList(allDoneLevelsString.split(","))); } super.onStart(); }
/** * onCreateView * * <p>handles the special case of the serverport entry which is an int.... */ @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); // prefs.registerOnSharedPreferenceChangeListener(this); for (String key : prefs.getAll().keySet()) { Preference pref = findPreference(key); if (pref == null) continue; if (key.equals("serverport")) pref.setSummary("" + prefs.getInt(key, 0)); else pref.setSummary(prefs.getString(key, key)); } return super.onCreateView(inflater, container, savedInstanceState); }