SHARE
TWEET

Untitled

a guest Jun 26th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
  2.      
  3. public View createSettingsOverlay(){
  4.     ViewGroup root = (ViewGroup)findViewById(R.id.absoluteOverlay);
  5.  
  6.     LayoutInflater inflater =  getLayoutInflater();
  7.     View result = inflater.inflate(R.layout.overlay_baloon_settings, root, false);
  8.  
  9.     ((TextView)result.findViewById(R.id.loginText)).setText(application.getCurrentlyLoggedUser());
  10.     ((TextView)result.findViewById(R.id.passwordText)).setText(application.getCurrenlyLoggedPass());
  11.     ((TextView)result.findViewById(R.id.loginTimeText)).setText(application.getTimeOfLogin().toString());  
  12.     ((TextView)result.findViewById(R.id.settings_popup_server_url)).setText(application.getCurrentUrl());
  13.  
  14.     //Emil Edit
  15.     CheckBox rememberMe = (CheckBox)result.findViewById(R.id.cbRememberMe);
  16.     //boolean rememberMePreference = PreferenceManager.getDefaultSharedPreferences(DynamicDataActivity.this).getBoolean(SettingsActivity.REMEMBER_ME_CHECKBOX_KEY, false);
  17.     Log.d(TAG, "Remember Me set in the preference is: " + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean(SettingsActivity.REMEMBER_ME_CHECKBOX_KEY, false));
  18.  
  19.     rememberMe.setChecked(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean(SettingsActivity.REMEMBER_ME_CHECKBOX_KEY, false));
  20.     rememberMe.setOnCheckedChangeListener(new OnCheckedChangeListener()
  21.     {
  22.         public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  23.             Log.d(TAG, "boolean isChecked is: " + isChecked);
  24.             if (isChecked)
  25.             {
  26.                 Log.d(TAG, "Remember me checkbox in setting overlay set to True");
  27.                 PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putBoolean(SettingsActivity.REMEMBER_ME_CHECKBOX_KEY, true);
  28.                 application.setRememberMeChecked(true);
  29.             }
  30.             else
  31.             {
  32.                 Log.d(TAG, "Remember me checkbox in setting overlay set to False");
  33.                 PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putBoolean(SettingsActivity.REMEMBER_ME_CHECKBOX_KEY, false);
  34.                 application.setRememberMeChecked(false);
  35.             }
  36.         }
  37.     });
  38.      
  39. SharedPreferences prefs = getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
  40. SharedPreferences.Editor editor = prefs.edit();
  41. editor.putBoolean("rememberMe", yourState);
  42. editor.commit();
  43.      
  44. SharedPreferences prefs = getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
  45. boolean state = prefs.getBoolean("rememberMe", state_by_default);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top