List of usage examples for android.content SharedPreferences getAll
Map<String, ?> getAll();
From source file:org.gluu.super_gluu.store.AndroidKeyDataStore.java
@Override public List<byte[]> getKeyHandlesByIssuerAndAppId(String issuer, String application) { List<byte[]> result = new ArrayList<byte[]>(); final SharedPreferences keySettings = context.getSharedPreferences(U2F_KEY_PAIR_FILE, Context.MODE_PRIVATE); Map<String, String> keyTokens = (Map<String, String>) keySettings.getAll(); for (Map.Entry<String, String> keyToken : keyTokens.entrySet()) { String tokenEntryString = keyToken.getValue(); TokenEntry tokenEntry = new Gson().fromJson(tokenEntryString, TokenEntry.class); if (((issuer == null) || StringUtils.equals(issuer, tokenEntry.getIssuer())) && ((application == null) || StringUtils.equals(application, tokenEntry.getApplication()))) { String keyHandleKey = keyToken.getKey(); try { byte[] keyHandle = keyToKeyHandle(keyHandleKey); result.add(keyHandle);/* www . j a va2 s. co m*/ } catch (DecoderException ex) { Log.e(TAG, "Invalid keyHandle: " + keyHandleKey, ex); } } } return result; }
From source file:com.ayogo.cordova.notification.ScheduledNotificationManager.java
public ScheduledNotification cancelNotification(String tag) { LOG.v(NotificationPlugin.TAG, "cancelNotification: " + tag); SharedPreferences prefs = getPrefs(); SharedPreferences.Editor editor = prefs.edit(); Map<String, ?> notifications = prefs.getAll(); ScheduledNotification notification = null; for (String key : notifications.keySet()) { try {/* w w w . ja v a 2 s.c om*/ JSONObject value = new JSONObject(notifications.get(key).toString()); String ntag = value.optString("tag"); LOG.v(NotificationPlugin.TAG, "checking Notification: " + value.toString()); if (ntag != null && ntag.equals(tag)) { LOG.v(NotificationPlugin.TAG, "found Notification: " + value.toString()); notification = new ScheduledNotification(value.optString("title", null), value); editor.remove(key); LOG.v(NotificationPlugin.TAG, "unscheduling Notification: "); //unschedule the alarm Intent intent = new Intent(context, TriggerReceiver.class); intent.setAction(ntag); PendingIntent pi = PendingIntent.getBroadcast(context, INTENT_REQUEST_CODE, intent, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(pi); } } catch (JSONException e) { } } editor.commit(); if (notification != null) { LOG.v(NotificationPlugin.TAG, "returning Notification " + notification.toString()); } else { LOG.v(NotificationPlugin.TAG, "could not find Notification " + tag); } return notification; }
From source file:de.appplant.cordova.plugin.notification.NotificationWrapper.java
/** * Cancel all notifications that were created by this plugin. * * Android can only unregister a specific alarm. There is no such thing * as cancelAll. Therefore we rely on the Shared Preferences which holds * all our alarms to loop through these alarms and unregister them one * by one./*w w w. j av a 2s .c o m*/ */ public void cancelAll() { SharedPreferences settings = getSharedPreferences(); NotificationManager nc = getNotificationManager(); Map<String, ?> alarms = settings.getAll(); Set<String> alarmIds = alarms.keySet(); for (String alarmId : alarmIds) { cancel(alarmId); } nc.cancelAll(); }
From source file:de.appplant.cordova.plugin.notification.NotificationWrapper.java
/** * Clear all notifications without canceling repeating alarms *//*from w w w .j a va2 s. c om*/ public void clearAll() { SharedPreferences settings = getSharedPreferences(); NotificationManager nc = getNotificationManager(); Map<String, ?> alarms = settings.getAll(); Set<String> alarmIds = alarms.keySet(); for (String alarmId : alarmIds) { clear(alarmId); } nc.cancelAll(); }
From source file:io.github.carlorodriguez.alarmon.AlarmClockService.java
public void fixPersistentSettings() { final String badDebugName = "DEBUG_MODE\""; final String badNotificationName = "NOTFICATION_ICON"; final String badLockScreenName = "LOCK_SCREEN\""; final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); Map<String, ?> prefNames = prefs.getAll(); // Don't do anything if the bad preferences have already been fixed. if (!prefNames.containsKey(badDebugName) && !prefNames.containsKey(badNotificationName) && !prefNames.containsKey(badLockScreenName)) { return;/*from w w w .jav a 2 s. co m*/ } Editor editor = prefs.edit(); if (prefNames.containsKey(badDebugName)) { editor.putString(AppSettings.DEBUG_MODE, prefs.getString(badDebugName, null)); editor.remove(badDebugName); } if (prefNames.containsKey(badNotificationName)) { editor.putBoolean(AppSettings.NOTIFICATION_ICON, prefs.getBoolean(badNotificationName, true)); editor.remove(badNotificationName); } if (prefNames.containsKey(badLockScreenName)) { editor.putString(AppSettings.LOCK_SCREEN, prefs.getString(badLockScreenName, null)); editor.remove(badLockScreenName); } editor.apply(); }
From source file:com.example.stan.recycler.activities.MainActivity.java
private void refreshItems() { RecyclerView recyclerView = findViewById(R.id.recycler); recyclerView.setLayoutManager(new LinearLayoutManager(this)); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); boolean wildfireRobotEnabled = false; boolean wildfireBotEnabled = false; boolean alternatePath = false; for (Map.Entry<String, ?> entry : sharedPrefs.getAll().entrySet()) { //Log.w("Key", entry.getKey()); if ("wildfirerobotbot enabled".equals(entry.getKey())) wildfireRobotEnabled = Boolean.parseBoolean(entry.getValue().toString()); if ("wildfirebot enabled".equals(entry.getKey())) wildfireBotEnabled = Boolean.parseBoolean(entry.getValue().toString()); if ("alternate path".equals(entry.getKey())) alternatePath = Boolean.parseBoolean(entry.getValue().toString()); if ("auto refresh enabled".equals(entry.getKey())) this.autoRefresh = Boolean.parseBoolean(entry.getValue().toString()); }//w w w .j a v a 2 s. c o m LogDownloader lg = new LogDownloader(wildfireRobotEnabled, wildfireBotEnabled, alternatePath); Thread thread = new Thread(lg); thread.start(); try { thread.join(); } catch (InterruptedException e) { Log.w("Error", e); } finally { recyclerView.setAdapter(new LogMessageRecyclerAdapter(lg.getLogMessages())); mSwipeRefreshLayout.setRefreshing(false); } }
From source file:com.kentli.cycletrack.RecordingActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.recording);/* w w w .j a v a 2 s. c o m*/ initWidget(); if (rService == null) rService = new Intent(RecordingActivity.this, RecordingService.class); startService(rService); ServiceConnection sc = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { } public void onServiceConnected(ComponentName name, IBinder service) { IRecordService rs = (IRecordService) service; recordService = rs; int state = rs.getState(); updateUIAccordingToState(rs.getState()); if (state > RecordingService.STATE_IDLE) { if (state == RecordingService.STATE_FULL) { startActivity(new Intent(RecordingActivity.this, SaveTrip.class)); } else { if (state == RecordingService.STATE_RECORDING) { isRecording = true; initTrip(); } //PAUSE or RECORDING... recordService.setListener(RecordingActivity.this); } } else { // First run? Switch to user prefs screen if there are no prefs stored yet SharedPreferences settings = getSharedPreferences("PREFS", 0); if (settings.getAll().isEmpty()) { showWelcomeDialog(); } } RecordingActivity.this.unbindService(this); // race? this says we no longer care // Before we go to record, check GPS status final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { buildAlertMessageNoGps(); } } }; // This needs to block until the onServiceConnected (above) completes. // Thus, we can check the recording status before continuing on. bindService(rService, sc, Context.BIND_AUTO_CREATE); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); //Google Map MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(this); setButtonOnClickListeners(); }
From source file:com.github.howeyc.slideshow.activities.SettingsActivity.java
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (sharedPreferences != null && key != null) { debug("CHANGED| Key:" + key + " ++ Value: " + sharedPreferences.getAll().get(key)); }/*from w ww . jav a 2 s .co m*/ if (editableTitleFields.contains(key)) { //update display/transition title updateFieldTitle(key); if (getString(R.string.sett_key_srctype).equals(key)) { createCat2Fields(); alarmScheduler.scheduleAlarm(); } } }
From source file:de.mkrtchyan.recoverytools.RashrActivity.java
/** * @return All Preferences as String//w w w.ja v a2s . c o m */ public String getAllPrefs() { SharedPreferences prefs = getSharedPreferences(Constants.PREF_NAME, MODE_PRIVATE); String Prefs = ""; Map<String, ?> prefsMap = prefs.getAll(); try { for (Map.Entry<String, ?> entry : prefsMap.entrySet()) { /** * Skip following Prefs (PREF_KEY_HISTORY, ...) */ try { if (!entry.getKey().contains(Constants.PREF_KEY_HISTORY) && !entry.getKey().contains(FlashUtil.PREF_KEY_FLASH_COUNTER)) { Prefs += entry.getKey() + ": " + entry.getValue().toString() + "\n"; } } catch (NullPointerException e) { mActivity.addError(Constants.RASHR_TAG, e, false); } } } catch (NullPointerException e) { mActivity.addError(Constants.RASHR_TAG, e, false); } return Prefs; }
From source file:fr.forexperts.ui.PortfolioFragment.java
@Override public void onStart() { super.onStart(); // Bind to Service Intent intent = new Intent(getActivity(), DataService.class); getActivity().bindService(intent, mConnection, Context.BIND_AUTO_CREATE); SharedPreferences prefs = getActivity().getSharedPreferences("portfolio", Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); Map<String, ?> values = prefs.getAll(); mData.clear();/*www . j a v a 2 s .co m*/ portfolioListAdapter.notifyDataSetChanged(); if (values.size() == 0) { mProgressBar.setVisibility(View.GONE); mAddButton.setVisibility(View.VISIBLE); } else { mProgressBar.setVisibility(View.VISIBLE); String code = ""; for (Map.Entry<String, ?> entre : values.entrySet()) { code = code + entre.getValue() + ","; } code = code.substring(0, code.length() - 1); editor.clear(); editor.apply(); AddTickerTask task = new AddTickerTask(); task.execute(code); } }