List of usage examples for android.content SharedPreferences getBoolean
boolean getBoolean(String key, boolean defValue);
From source file:com.onesignal.OneSignal.java
static boolean getVibrate(Context context) { final SharedPreferences prefs = getGcmPreferences(context); return prefs.getBoolean("GT_VIBRATE_ENABLED", true); }
From source file:com.onesignal.OneSignal.java
static boolean getSoundEnabled(Context context) { final SharedPreferences prefs = getGcmPreferences(context); return prefs.getBoolean("GT_SOUND_ENABLED", true); }
From source file:com.onesignal.OneSignal.java
static boolean getNotificationsWhenActiveEnabled(Context context) { final SharedPreferences prefs = getGcmPreferences(context); return prefs.getBoolean("ONESIGNAL_ALWAYS_SHOW_NOTIF", false); }
From source file:com.onesignal.OneSignal.java
static boolean getInAppAlertNotificationEnabled(Context context) { final SharedPreferences prefs = getGcmPreferences(context); return prefs.getBoolean("ONESIGNAL_INAPP_ALERT", false); }
From source file:com.asksven.commandcenter.valueobjects.CollectionManager.java
/** * Returns the list of available commands to the Locale plugin (if plugin enabled) * @return a list of allowed commands to be called by the plugin *//* ww w . ja v a 2 s. c o m*/ public ArrayList<String> getAvailableCommandsForPlugin() { ArrayList<String> myRet = new ArrayList<String>(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(m_context); boolean bAllowPlugin = preferences.getBoolean("allowPlugin", false); if (!bAllowPlugin) { Log.i(TAG, "Plugin accesd is disabled: Returning message"); myRet.add("Plugin access is disabled"); return myRet; } Set<String> collections = this.getCollectionNames(); Iterator<String> it = collections.iterator(); while (it.hasNext()) { // Get element String collectionName = it.next(); CommandCollection collection = this.getCollectionByName(collectionName, false); for (int i = 0; i < collection.getEntries().size(); i++) { Command command = collection.getEntries().get(i); if (command.getCommandValues().equals("")) { myRet.add(command.getCommand()); } } } Log.i(TAG, "Returning " + myRet.size() + " commands to plugin"); return myRet; }
From source file:com.asksven.commandcenter.valueobjects.CollectionManager.java
/** * Returns the command object given a command (if Plugin enabled) * @param strCommand the command//from w w w .ja va 2s. c o m * @return a Command object is any was found */ public Command getCommandByString(String strCommand) { Log.i(TAG, "Plugin trying to retrieve command: " + strCommand); Command myRet = null; SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(m_context); boolean bAllowPlugin = preferences.getBoolean("allowPlugin", false); if (!bAllowPlugin) { Log.i(TAG, "Plugin accesd is disabled: Returning null"); return myRet; } Set<String> collections = this.getCollectionNames(); Iterator<String> it = collections.iterator(); while (it.hasNext()) { // Get element String collectionName = it.next(); CommandCollection collection = this.getCollectionByName(collectionName, false); for (int i = 0; i < collection.getEntries().size(); i++) { Command command = collection.getEntries().get(i); if (command.getCommand().equals(strCommand)) { // return only commands for batch.... they can not contain values if (command.getCommandValues().equals("")) { myRet = command; Log.i(TAG, "Command returned: " + command.toString()); break; } } } } return myRet; }
From source file:com.browsertophone.C2DMReceiver.java
@Override public void onMessage(Context context, Intent intent) { Bundle extras = intent.getExtras();// w w w. j a v a 2 s . c o m if (extras != null) { String url = (String) extras.get("url"); String title = (String) extras.get("title"); String sel = (String) extras.get("sel"); String debug = (String) extras.get("debug"); if (debug != null) { // server-controlled debug - the server wants to know // we received the message, and when. This is not user-controllable, // we don't want extra traffic on the server or phone. Server may // turn this on for a small percentage of requests or for users // who report issues. DefaultHttpClient client = new DefaultHttpClient(); HttpGet get = new HttpGet(AppEngineClient.BASE_URL + "/debug?id=" + extras.get("collapse_key")); // No auth - the purpose is only to generate a log/confirm delivery // (to avoid overhead of getting the token) try { client.execute(get); } catch (ClientProtocolException e) { // ignore } catch (IOException e) { // ignore } } if (title != null && url != null && url.startsWith("http")) { SharedPreferences settings = Prefs.get(context); Intent launchIntent = LauncherUtils.getLaunchIntent(context, title, url, sel); // Notify and optionally start activity if (settings.getBoolean("launchBrowserOrMaps", true) && launchIntent != null) { LauncherUtils.playNotificationSound(context); context.startActivity(launchIntent); } else { if (sel != null && sel.length() > 0) { // have selection LauncherUtils.generateNotification(context, sel, context.getString(R.string.copied_desktop_clipboard), launchIntent); } else { LauncherUtils.generateNotification(context, url, title, launchIntent); } } // Record history (for link/maps only) if (launchIntent != null && launchIntent.getAction().equals(Intent.ACTION_VIEW)) { HistoryDatabase.get(context).insertHistory(title, url); } } } }
From source file:com.menumomma.chrome2phone.C2DMReceiver.java
@Override public void onMessage(Context context, Intent intent) { Bundle extras = intent.getExtras();/*from w w w .ja v a2s .c o m*/ if (extras != null) { String url = (String) extras.get("url"); String title = (String) extras.get("title"); String sel = (String) extras.get("sel"); String debug = (String) extras.get("debug"); if (debug != null) { // server-controlled debug - the server wants to know // we received the message, and when. This is not user-controllable, // we don't want extra traffic on the server or phone. Server may // turn this on for a small percentage of requests or for users // who report issues. DefaultHttpClient client = new DefaultHttpClient(); HttpGet get = new HttpGet(Config.BASE_URL + "/debug?id=" + extras.get("collapse_key")); // No auth - the purpose is only to generate a log/confirm delivery // (to avoid overhead of getting the token) try { client.execute(get); } catch (ClientProtocolException e) { // ignore } catch (IOException e) { // ignore } } if (title != null && url != null && url.startsWith("http")) { SharedPreferences settings = Prefs.get(context); Intent launchIntent = LauncherUtils.getLaunchIntent(context, title, url, sel); // Notify and optionally start activity if (settings.getBoolean("launchBrowserOrMaps", true) && launchIntent != null) { try { context.startActivity(launchIntent); LauncherUtils.playNotificationSound(context); } catch (ActivityNotFoundException e) { return; } } else { LauncherUtils.generateNotification(context, url, title, launchIntent); } // Record history (for link/maps only) if (launchIntent != null && launchIntent.getAction().equals(Intent.ACTION_VIEW)) { HistoryDatabase.get(context).insertHistory(title, url); } } } }
From source file:cl.mmoscoso.geocomm.sync.GeoCommGetRoutesAsyncTask.java
/** * /*www. j a va2s .com*/ */ @Override protected void onPostExecute(Boolean result) { mProgressDialog.dismiss(); if (result) { //Toast.makeText(this.context,R.string.mssg_taskcompleted, Toast.LENGTH_SHORT).show(); GeoCommListRoutesAdapter adapter = new GeoCommListRoutesAdapter(context, list_routes); this.listview.setAdapter(adapter); try { ((GeoCommMainActivity) this.context).storage(); } catch (Exception e) { // TODO: handle exception } try { SharedPreferences preferences = this.context.getSharedPreferences("userInformation", context.MODE_PRIVATE); Boolean is_allroutes = preferences.getBoolean("is_allroutes", false); if (is_allroutes) { ((GeoCommOpcionUserActivity) this.context).showRoutesOwner(); } } catch (Exception e) { // TODO: handle exception } } else { Toast.makeText(this.context, R.string.error_cantgetroutes, Toast.LENGTH_SHORT).show(); } }
From source file:com.baxtern.android.websms.connector.exetel.ConnectorExetel.java
/** * {@inheritDoc}/*from w w w .j av a 2 s . com*/ */ @Override public final ConnectorSpec updateSpec(final Context context, final ConnectorSpec connectorSpec) { final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context); if (p.getBoolean(Preferences.PREFS_ENABLED, false)) { if (p.getString(Preferences.PREFS_USER, "").length() > 0 && p.getString(Preferences.PREFS_PASSWORD, "").length() > 0) { connectorSpec.setReady(); } else { connectorSpec.setStatus(ConnectorSpec.STATUS_ENABLED); } } else { connectorSpec.setStatus(ConnectorSpec.STATUS_INACTIVE); } return connectorSpec; }