List of usage examples for android.app Activity getSharedPreferences
@Override public SharedPreferences getSharedPreferences(String name, int mode)
From source file:edu.rowan.app.fragments.FoodRatingFragment.java
private static void getUserID(final Activity reference) { JsonQueryManager jsonQuery = JsonQueryManager.getInstance(reference); Map<String, String> params = new HashMap<String, String>(); params.put("ostype", Build.MANUFACTURER + ", " + Build.MODEL + " version: " + Build.VERSION.SDK_INT); jsonQuery.requestJson(CREATE_USER_ADDR, params, new Callback() { @Override// www . ja v a 2 s . co m public void receiveJson(JSONObject json, String origin) { try { if (origin == CREATE_USER_ADDR) { if (json != null) { SharedPreferences prefs = reference.getSharedPreferences(PREFS, 0); Editor edit = prefs.edit(); edit.putString(USER_ID, json.getString(USER_ID)); edit.commit(); Log.d("Homescreen", "received json: " + json.getString("userID")); } } } catch (JSONException e) { e.printStackTrace(); } } }); }
From source file:org.pixmob.droidlink.ui.AccountInitTask.java
public AccountInitTask(final Fragment fragment) { this.fragment = fragment; final Activity context = fragment.getActivity(); prefs = context.getSharedPreferences(SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE); prefsEditor = prefs.edit();//from w w w . j a v a2 s .co m contentResolver = context.getContentResolver(); accounts = Accounts.list(context); }
From source file:com.nikhilnayak.games.octoshootar.ui.fragments.GameModeFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); mPlayerProfile = new PlayerProfile( activity.getSharedPreferences(PlayerProfile.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)); if (activity instanceof GameModeFragment.Listener) { //show play button mListener = (GameModeFragment.Listener) activity; }//from w w w . ja va 2s . c o m }
From source file:net.texh.cordovapluginstepcounter.CordovaStepCounter.java
@Override public void onStart() { Activity activity = this.cordova.getActivity(); SharedPreferences sharedPref = activity.getSharedPreferences(USER_DATA_PREF, Context.MODE_PRIVATE); Boolean pActive = this.getPedometerIsActive(sharedPref); if (pActive) { if (stepCounterIntent == null) { stepCounterIntent = new Intent(activity, StepCounterService.class); activity.startService(stepCounterIntent); }/*from w w w. j av a2s .c om*/ if (!bound) { activity.bindService(stepCounterIntent, mConnection, Context.BIND_AUTO_CREATE); } } super.onStart(); }
From source file:com.nikhilnayak.games.octoshootar.ui.fragments.ProfileFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); if (activity instanceof ProfileFragment.Listener) { mListener = (ProfileFragment.Listener) activity; mPlayerProfile = new PlayerProfile( activity.getSharedPreferences(PlayerProfile.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)); } else {/*from w w w . jav a 2 s . com*/ throw new ClassCastException(activity.toString() + " must implement ProfileFragment.Listener"); } }
From source file:org.dmfs.webcal.fragments.PagerFragment.java
@Override public void onDetach() { // avoid to get notifications for changes in the shared preferences that we caused ourselves (because the active section has been stored) Activity activity = getActivity(); activity.getSharedPreferences(activity.getPackageName() + "_preferences", 0) .unregisterOnSharedPreferenceChangeListener(this); super.onDetach(); }
From source file:com.nikhilnayak.games.octoshootar.ui.fragments.GameModeChooserFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); if (activity instanceof GameScoreFragment.Listener) { mListener = (GameModeChooserFragment.Listener) activity; mPlayerProfile = new PlayerProfile( activity.getSharedPreferences(PlayerProfile.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)); } else {//w w w . j a v a 2s . com throw new ClassCastException(activity.toString() + " must implement GameModeChooserFragment.Listener"); } }
From source file:com.nikhilnayak.games.octoshootar.ui.fragments.GameModeDetailsFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); if (activity instanceof GameModeDetailsFragment.Listener) { mListener = (GameModeDetailsFragment.Listener) activity; mPlayerProfile = new PlayerProfile( activity.getSharedPreferences(PlayerProfile.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)); } else {/* ww w.ja v a 2 s .c om*/ throw new ClassCastException(activity.toString() + " must implemenet GameModeDetailsFragment.Listener"); } }
From source file:com.nikhilnayak.games.octoshootar.ui.fragments.BonusFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); if (activity instanceof BonusFragment.Listener) { mListener = (BonusFragment.Listener) activity; mPlayerProfile = new PlayerProfile( activity.getSharedPreferences(PlayerProfile.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)); } else {/*from w w w. j ava 2 s .co m*/ throw new ClassCastException(activity.toString() + " must implement BonusFragment.Listener"); } }
From source file:org.dmfs.webcal.fragments.PagerFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); activity.getSharedPreferences(activity.getPackageName() + "_preferences", 0) .registerOnSharedPreferenceChangeListener(this); }