List of usage examples for android.os UserHandle USER_CURRENT
int USER_CURRENT
To view the source code for android.os UserHandle USER_CURRENT.
Click Source Link
From source file:com.android.systemui.ReminderReceiver.java
@Override public void onReceive(final Context context, Intent intent) { NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); SharedPreferences shared = context.getSharedPreferences(KEY_REMINDER_ACTION, Context.MODE_PRIVATE); if (intent.getBooleanExtra("clear", false)) { manager.cancel(NOTI_ID);//from w w w . j av a2s . co m // User has set a new reminder but didn't clear // This notification until now if (!shared.getBoolean("updated", false)) { shared.edit().putBoolean("scheduled", false).commit(); shared.edit().putInt("hours", -1).commit(); shared.edit().putInt("minutes", -1).commit(); shared.edit().putInt("day", -1).commit(); shared.edit().putString("title", null).commit(); shared.edit().putString("message", null).commit(); } } else { String title = shared.getString("title", null); String message = shared.getString("message", null); if (title != null && message != null) { Bitmap bm = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_qs_alarm_on); NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setTicker(title) .setContentTitle(title).setContentText(message).setAutoCancel(false).setOngoing(true) .setPriority(NotificationCompat.PRIORITY_HIGH).setSmallIcon(R.drawable.ic_qs_alarm_on) .setLargeIcon(bm).setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE) .setStyle(new NotificationCompat.BigTextStyle().bigText(message)); int alertMode = Settings.System.getIntForUser(context.getContentResolver(), Settings.System.REMINDER_ALERT_NOTIFY, 0, UserHandle.USER_CURRENT); PendingIntent result = null; Intent serviceIntent = new Intent(context, ReminderService.class); if (alertMode != 0 && !QuietHoursHelper.inQuietHours(context, Settings.System.QUIET_HOURS_MUTE)) { context.startService(serviceIntent); } // Stop sound on click serviceIntent.putExtra("stopSelf", true); result = PendingIntent.getService(context, 1, serviceIntent, PendingIntent.FLAG_CANCEL_CURRENT); builder.setContentIntent(result); // Add button for dismissal serviceIntent.putExtra("dismissNoti", true); result = PendingIntent.getService(context, 0, serviceIntent, PendingIntent.FLAG_CANCEL_CURRENT); builder.addAction(R.drawable.ic_sysbar_null, context.getResources().getString(R.string.quick_settings_reminder_noti_dismiss), result); // Add button for reminding later serviceIntent.putExtra("time", true); result = PendingIntent.getService(context, 2, serviceIntent, PendingIntent.FLAG_CANCEL_CURRENT); builder.addAction(R.drawable.ic_qs_alarm_on, context.getResources().getString(R.string.quick_settings_reminder_noti_later), result); shared.edit().putBoolean("scheduled", false).commit(); shared.edit().putInt("hours", -1).commit(); shared.edit().putInt("minutes", -1).commit(); shared.edit().putInt("day", -1).commit(); manager.notify(NOTI_ID, builder.build()); } } shared.edit().putBoolean("updated", false).commit(); }
From source file:com.android.settings.accessibility.AccessibilitySettings.java
private void handleToggleMasterMonoPreferenceClick() { Settings.System.putIntForUser(getContentResolver(), Settings.System.MASTER_MONO, mToggleMasterMonoPreference.isChecked() ? 1 : 0, UserHandle.USER_CURRENT); }
From source file:com.android.settings.accessibility.AccessibilitySettings.java
private void updateMasterMono() { final boolean masterMono = Settings.System.getIntForUser(getContentResolver(), Settings.System.MASTER_MONO, 0 /* default */, UserHandle.USER_CURRENT) == 1; mToggleMasterMonoPreference.setChecked(masterMono); }