List of usage examples for android.content SharedPreferences getBoolean
boolean getBoolean(String key, boolean defValue);
From source file:com.njlabs.amrita.aid.info.Calender.java
@Override public void init(Bundle savedInstanceState) { setupLayout(R.layout.activity_calender, Color.parseColor("#fe5352")); final Calender thisContext = this; descriptions = new HashMap<>(); backgroundColors = new HashMap<>(); textColors = new HashMap<>(); SharedPreferences preferences = getSharedPreferences("app_extra", Context.MODE_PRIVATE); Boolean AgreeStatus = preferences.getBoolean("calender_agree", false); if (!AgreeStatus) { AlertDialog.Builder builder = new AlertDialog.Builder(thisContext); builder.setTitle("Academic Calender").setIcon(R.drawable.ic_action_info_small).setMessage( "Red denotes that it's an Exam day. Blue denotes an event (not a Holiday). Whereas Green denotes a Holiday. I'm not resposibile for the accuracy of the dates") .setCancelable(false).setPositiveButton("I Agree", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { SharedPreferences preferences = getSharedPreferences("app_extra", Context.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean("calender_agree", true); editor.apply();/*from w w w . j a v a2 s . c o m*/ } }); AlertDialog alert = builder.create(); alert.show(); } caldroidFragment = new CaldroidFragment(); if (savedInstanceState != null) { caldroidFragment.restoreStatesFromKey(savedInstanceState, "CALDROID_SAVED_STATE"); } else { Bundle args = new Bundle(); Calendar cal = Calendar.getInstance(); args.putInt(CaldroidFragment.MONTH, cal.get(Calendar.MONTH) + 1); args.putInt(CaldroidFragment.YEAR, cal.get(Calendar.YEAR)); args.putBoolean(CaldroidFragment.ENABLE_SWIPE, true); caldroidFragment.setArguments(args); } setCustomResourceForDates(); FragmentTransaction t = getSupportFragmentManager().beginTransaction(); t.replace(R.id.calendar, caldroidFragment); t.commit(); final CaldroidListener listener = new CaldroidListener() { @Override public void onSelectDate(Date date, View view) { if (!formatter.format(date).equals("")) { String description = descriptions.get(formatter.format(date)); if (description != null && !description.equals("")) { AlertDialog.Builder builder = new AlertDialog.Builder(thisContext); builder.setMessage(description).setCancelable(true).setPositiveButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); } } } }; caldroidFragment.setCaldroidListener(listener); }
From source file:org.lumicall.android.sip.RegisterAccount.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); startService(new Intent(this, GMonitorService.class)); // Has user already done registration or activation? LumicallDataSource ds = new LumicallDataSource(this); ds.open();//from ww w .j av a2 s . c o m int pendingAccounts = ds.getSIP5060ProvisioningRequests().size(); int createdAccounts = ds.getSIPIdentities().size(); ds.close(); SharedPreferences settings = getSharedPreferences(PREFS_FILE, MODE_PRIVATE); boolean advancedSetup = settings.getBoolean(PREF_ADVANCED_SETUP, false); if (advancedSetup || createdAccounts > 0) { doMainActivity(); return; } setContentView(R.layout.register_dialog); setTitle(R.string.reg_title); buttonOK = (Button) findViewById(R.id.Button01); buttonOK.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { doSIP5060Provisioning(); } }); buttonManual = (Button) findViewById(R.id.ButtonTryManual); buttonManual.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { doManualVerification(); } }); otherProviderSetup = (TextView) findViewById(R.id.OtherProviderSetup); otherProviderSetup.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { otherProviderSetup(); } }); }
From source file:edu.asu.msse.sgowdru.moviemediaplayerrpc.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //This will run only once when the app is first installed to load all movie details from RPC //By using shared preference variables SharedPreferences settings = getSharedPreferences("PREFS_NAME", 0); boolean mboolean = settings.getBoolean("FIRST_RUN", false); if (!mboolean) { // do the thing for the first time settings = getSharedPreferences("PREFS_NAME", 0); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("FIRST_RUN", true); editor.commit();// ww w .jav a 2s . co m try { db = new MoviesDB(this); crsDB = db.openDB(); loadRPCMovies(); } catch (Exception e) { System.out.println("Exception message " + e.getMessage()); } } //In this method we process all the data and push it to expandable list view processData(); //adapter.notifyDataSetChanged(); }
From source file:cl.mmoscoso.geocomm.sync.GeoCommGetRoutesOwnerAsyncTask.java
@Override protected Boolean doInBackground(String... params) { // TODO Auto-generated method stub HttpClient httpclient = new DefaultHttpClient(); HttpParams httpParams = httpclient.getParams(); httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 10000); httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, 10000); HttpPost httppost = new HttpPost(this.hostname); Log.i(TAGNAME, "Try to connect to " + this.hostname); try {/*from w ww . j ava 2 s .c o m*/ List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1); nameValuePairs.add(new BasicNameValuePair("id", Integer.toString(this.id_user))); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); Log.i(TAGNAME, "Post Request"); HttpResponse response = httpclient.execute(httppost); int responseCode = response.getStatusLine().getStatusCode(); switch (responseCode) { default: Toast.makeText(this.context, R.string.error_not200code, Toast.LENGTH_SHORT).show(); break; case 200: HttpEntity entity = response.getEntity(); if (entity != null) { String responseBody = EntityUtils.toString(entity); //Log.i(TAGNAME, responseBody); JSONObject jObj, ruta; try { Log.i(TAGNAME, "Reading JSONResponse"); jObj = new JSONObject(responseBody); SharedPreferences preferences = this.context.getSharedPreferences("userInformation", context.MODE_PRIVATE); Boolean is_allroutes = preferences.getBoolean("is_allroutes", false); for (int i = 0; i < jObj.length(); i++) { ruta = new JSONObject(jObj.getString(jObj.names().getString(i))); if (is_allroutes) { if (ruta.getBoolean("public") == false) { list_routes.add(new GeoCommRoute(ruta.getString("name"), ruta.getString("owner"), ruta.getInt("id"), ruta.getInt("totalPoints"), ruta.getString("description"), ruta.getBoolean("public"))); } } else list_routes.add(new GeoCommRoute(ruta.getString("name"), ruta.getString("owner"), ruta.getInt("id"), ruta.getInt("totalPoints"), ruta.getString("description"), ruta.getBoolean("public"))); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } break; } } catch (ClientProtocolException e) { // TODO Auto-generated catch block Log.e(TAGNAME, e.toString()); return false; } catch (IOException e) { // TODO Auto-generated catch block Log.e(TAGNAME, e.toString()); return false; } return true; }
From source file:es.uniovi.imovil.fcrtrainer.highscores.HighscoresFragment.java
private boolean firstTime() { SharedPreferences sharedPreferences = getActivity().getSharedPreferences(PREFERENCES, Context.MODE_PRIVATE); boolean defaultValue = true; boolean firstTime = sharedPreferences.getBoolean(FIRST_TIME_HIGHSCORES, defaultValue); if (firstTime) { SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putBoolean(FIRST_TIME_HIGHSCORES, false); editor.commit();//w w w. j a v a 2 s . com return true; } return false; }
From source file:com.playcez.GooglePlus.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Intent intent = getIntent(); if (intent == null || !intent.hasExtra("token")) { AuthUtils.refreshAuthToken(this); return;/*from w ww . java 2 s .co m*/ } setContentView(R.layout.activity_list); mListView = (ListView) findViewById(R.id.activityList); loginProgress = ProgressDialog.show(GooglePlus.this, "Please wait", "Autheticating...", true); AsyncTask<String, Void, List<Activity>> task = new AsyncTask<String, Void, List<Activity>>() { @Override protected List<Activity> doInBackground(String... params) { try { plus = new PlusWrap(GooglePlus.this).get(); Person mePerson = plus.people().get("me").execute(); Log.d(TAG, "ID:\t" + mePerson.getId()); Log.d(TAG, "Display Name:\t" + mePerson.getDisplayName()); Log.d(TAG, "Image URL:\t" + mePerson.getImage().getUrl()); Log.d(TAG, "Profile URL:\t" + mePerson.getUrl()); final String TOKEN = "access_token"; SharedPreferences myData = getSharedPreferences("myData", MODE_PRIVATE); Editor edit = myData.edit(); edit.putString(TOKEN, "access_token"); edit.putString("uid", mePerson.getId()); edit.commit(); Log.d(TAG, "hererre"); String placesLived = ""; String name = ""; String json = ""; JSONArray obj = null; try { name = mePerson.getDisplayName().toString(); placesLived = mePerson.getPlacesLived().toString(); List<PersonPlacesLived> object = mePerson.getPlacesLived(); json = object.toString(); obj = new JSONArray(json); json = obj.toString(); } catch (Exception e) { e.printStackTrace(); } final SharedPreferences settings = getSharedPreferences(AuthUtils.PREFS_NAME, 0); final String account_name = settings.getString(AuthUtils.PREF_ACCOUNT_NAME, ""); final String accessToken = settings.getString("accessToken", null); sendToServer("https://playcez.com/api_getUID.php", name, mePerson.getBirthday(), mePerson.getId(), mePerson.getCurrentLocation(), obj, mePerson.getGender(), accessToken, account_name); return plus.activities().list("me", "public").execute().getItems(); } catch (IOException e) { loginProgress.dismiss(); Toast.makeText(getApplicationContext(), "Check your network connection!", Toast.LENGTH_LONG) .show(); Log.e(TAG, "Unable to list recommended people for user: " + params[0], e); } return null; } @Override protected void onPostExecute(List<Activity> feed) { if (feed != null) { Log.d(TAG, feed + ""); SharedPreferences data = getSharedPreferences("myData", MODE_PRIVATE); boolean showTut = data.getBoolean("showTut", true); Editor myEdit = data.edit(); myEdit.putBoolean("showTut", false); myEdit.commit(); if (showTut) { startActivity(new Intent(getApplicationContext(), Tutorial3.class)); } else { startActivity(new Intent(getApplicationContext(), Start_Menu.class)); } finish(); } else { } } }; task.execute("me"); }
From source file:net.sf.diningout.app.AppApplication.java
/** * Move non-user setting preferences from default to app preferences. *///from w ww . ja va2 s .c om private void migrateAppPrefs() { SharedPreferences def = Prefs.get(this); Editor editDef = def.edit(); SharedPreferences app = Prefs.get(this, APP); Editor editApp = app.edit(); if (def.contains(ACCOUNT_INITIALISED)) { editApp.putBoolean(ACCOUNT_INITIALISED, def.getBoolean(ACCOUNT_INITIALISED, false)); editDef.remove(ACCOUNT_INITIALISED); } if (def.contains(ACCOUNT_NAME)) { editApp.putString(ACCOUNT_NAME, def.getString(ACCOUNT_NAME, null)); editDef.remove(ACCOUNT_NAME); } if (def.contains(CLOUD_ID)) { editApp.putString(CLOUD_ID, def.getString(CLOUD_ID, null)); editDef.remove(CLOUD_ID); } if (def.contains(INSTALL_ID)) { editApp.putLong(INSTALL_ID, def.getLong(INSTALL_ID, 0L)); editDef.remove(INSTALL_ID); } if (def.contains(LAST_SYNC)) { editApp.putLong(LAST_SYNC, def.getLong(LAST_SYNC, 0L)); editDef.remove(LAST_SYNC); } if (def.contains(NAVIGATION_DRAWER_OPENED)) { editApp.putBoolean(NAVIGATION_DRAWER_OPENED, def.getBoolean(NAVIGATION_DRAWER_OPENED, false)); editDef.remove(NAVIGATION_DRAWER_OPENED); } if (def.contains(ONBOARDED)) { editApp.putBoolean(ONBOARDED, def.getBoolean(ONBOARDED, false)); editDef.remove(ONBOARDED); } editDef.apply(); editApp.apply(); }
From source file:org.envirocar.app.application.UploadManager.java
public boolean isObfuscationEnabled() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); return prefs.getBoolean(SettingsActivity.OBFUSCATE_POSITION, false); }
From source file:com.arisprung.tailgate.GCMIntentService.java
@Override protected void onMessage(Context context, Intent intent) { Log.i(TAG, "Received message"); if (mTailgateSharedPreferences == null) mTailgateSharedPreferences = TailGateSharedPreferences.getInstance(getApplicationContext()); // String message = getString(R.string.gcm_message); // displayMessage(context, message); // notifies user // May return null if a EasyTracker has not yet been initialized with a // property ID. String strJson = intent.getStringExtra("json_message"); JSONObject jObj = null;/*from w ww. j a v a 2 s . c o m*/ try { jObj = new JSONObject(strJson); } catch (JSONException e) { e.printStackTrace(); } MessageBean message = JsonUtil.parseJsonToMessageBean(jObj); // EasyTracker easyTracker = EasyTracker.getInstance(context); // if (easyTracker != null) // { // // MapBuilder.createEvent().build() returns a Map of event fields and values // // that are set and sent with the hit. // easyTracker.send(MapBuilder.createEvent("backround_service", // Event category (required) // "OnMessage", // Event action (required) // "message_recieved", // Event label // Long.valueOf(message.getFaceID())) // Event value // .build()); // } if (!message.getFaceID().equals( mTailgateSharedPreferences.getStringSharedPreferences(TailGateSharedPreferences.FACEBOOK_ID, ""))) { TailGateUtility.addMessageDB(message, context); SharedPreferences mySharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean notify_checkbox_preference = mySharedPreferences.getBoolean("notification_preference", true); if (notify_checkbox_preference) { generateNotification(context, message); } } if (jObj.has("json_array_location")) { parseLocationJSON(jObj); } }
From source file:com.amazon.cordova.plugin.ADMMessageHandler.java
/** * Gets "shownotificationmessage" config option * /* w ww .j a v a 2s. co m*/ * @return returns boolean- true is shownotificationmessage is set to true in config.xml/sharedPreferences otherwise false */ private boolean shouldShowMessageInNotification() { //check if have cached copy of this option if (TextUtils.isEmpty(defaultOfflineMessage)) { //need to read it from sharedPreferences SharedPreferences config = this.getApplicationContext().getSharedPreferences(PREFS_NAME, 0); if (config != null) { shouldShowOfflineMessage = config.getBoolean(SHOW_MESSAGE_PREF, true); } } return shouldShowOfflineMessage; }