List of usage examples for android.content Intent ACTION_CLOSE_SYSTEM_DIALOGS
String ACTION_CLOSE_SYSTEM_DIALOGS
To view the source code for android.content Intent ACTION_CLOSE_SYSTEM_DIALOGS.
Click Source Link
From source file:org.sipdroid.sipua.ui.Receiver.java
public static void onState(int state, String caller) { if (ccCall == null) { ccCall = new Call(); ccConn = new Connection(); ccCall.setConn(ccConn);//from w w w.j a va 2 s . c o m ccConn.setCall(ccCall); } if (call_state != state) { if (state != UserAgent.UA_STATE_IDLE) call_end_reason = -1; call_state = state; switch (call_state) { case UserAgent.UA_STATE_INCOMING_CALL: enable_wifi(true); RtpStreamReceiver.good = RtpStreamReceiver.lost = RtpStreamReceiver.loss = RtpStreamReceiver.late = 0; RtpStreamReceiver.speakermode = speakermode(); bluetooth = -1; String text = caller.toString(); if (text.indexOf("<sip:") >= 0 && text.indexOf("@") >= 0) text = text.substring(text.indexOf("<sip:") + 5, text.indexOf("@")); String text2 = caller.toString(); if (text2.indexOf("\"") >= 0) text2 = text2.substring(text2.indexOf("\"") + 1, text2.lastIndexOf("\"")); broadcastCallStateChanged("RINGING", caller); mContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); ccCall.setState(Call.State.INCOMING); ccConn.setUserData(null); ccConn.setAddress(text, text2); ccConn.setIncoming(true); ccConn.date = System.currentTimeMillis(); ccCall.base = 0; AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); int rm = am.getRingerMode(); int vs = am.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER); KeyguardManager mKeyguardManager = (KeyguardManager) mContext .getSystemService(Context.KEYGUARD_SERVICE); if (v == null) v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); if ((pstn_state == null || pstn_state.equals("IDLE")) && PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean( org.sipdroid.sipua.ui.Settings.PREF_AUTO_ON, org.sipdroid.sipua.ui.Settings.DEFAULT_AUTO_ON) && !mKeyguardManager.inKeyguardRestrictedInputMode()) v.vibrate(vibratePattern, 1); else { if ((pstn_state == null || pstn_state.equals("IDLE")) && (rm == AudioManager.RINGER_MODE_VIBRATE || (rm == AudioManager.RINGER_MODE_NORMAL && vs == AudioManager.VIBRATE_SETTING_ON))) v.vibrate(vibratePattern, 1); if (am.getStreamVolume(AudioManager.STREAM_RING) > 0) { String sUriSipRingtone = PreferenceManager.getDefaultSharedPreferences(mContext).getString( org.sipdroid.sipua.ui.Settings.PREF_SIPRINGTONE, Settings.System.DEFAULT_RINGTONE_URI.toString()); if (!TextUtils.isEmpty(sUriSipRingtone)) { oRingtone = RingtoneManager.getRingtone(mContext, Uri.parse(sUriSipRingtone)); if (oRingtone != null) oRingtone.play(); } } } moveTop(); if (wl == null) { PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "Sipdroid.onState"); } wl.acquire(); Checkin.checkin(true); break; case UserAgent.UA_STATE_OUTGOING_CALL: RtpStreamReceiver.good = RtpStreamReceiver.lost = RtpStreamReceiver.loss = RtpStreamReceiver.late = 0; RtpStreamReceiver.speakermode = speakermode(); bluetooth = -1; onText(MISSED_CALL_NOTIFICATION, null, 0, 0); engine(mContext).register(); broadcastCallStateChanged("OFFHOOK", caller); ccCall.setState(Call.State.DIALING); ccConn.setUserData(null); ccConn.setAddress(caller, caller); ccConn.setIncoming(false); ccConn.date = System.currentTimeMillis(); ccCall.base = 0; moveTop(); Checkin.checkin(true); break; case UserAgent.UA_STATE_IDLE: broadcastCallStateChanged("IDLE", null); onText(CALL_NOTIFICATION, null, 0, 0); ccCall.setState(Call.State.DISCONNECTED); if (listener_video != null) listener_video.onHangup(); stopRingtone(); if (wl != null && wl.isHeld()) wl.release(); mContext.startActivity(createIntent(InCallScreen.class)); ccConn.log(ccCall.base); ccConn.date = 0; engine(mContext).listen(); break; case UserAgent.UA_STATE_INCALL: broadcastCallStateChanged("OFFHOOK", null); if (ccCall.base == 0) { ccCall.base = SystemClock.elapsedRealtime(); } progress(); ccCall.setState(Call.State.ACTIVE); stopRingtone(); if (wl != null && wl.isHeld()) wl.release(); mContext.startActivity(createIntent(InCallScreen.class)); break; case UserAgent.UA_STATE_HOLD: onText(CALL_NOTIFICATION, mContext.getString(R.string.card_title_on_hold), android.R.drawable.stat_sys_phone_call_on_hold, ccCall.base); ccCall.setState(Call.State.HOLDING); if (InCallScreen.started && (pstn_state == null || !pstn_state.equals("RINGING"))) mContext.startActivity(createIntent(InCallScreen.class)); break; } pos(true); RtpStreamReceiver.ringback(false); } }
From source file:com.android.deskclock.alarms.AlarmActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final long instanceId = AlarmInstance.getId(getIntent().getData()); mAlarmInstance = AlarmInstance.getInstance(getContentResolver(), instanceId); if (mAlarmInstance == null) { // The alarm was deleted before the activity got created, so just finish() LogUtils.e(LOGTAG, "Error displaying alarm for intent: %s", getIntent()); finish();// w ww . j av a 2s .c om return; } else if (mAlarmInstance.mAlarmState != AlarmInstance.FIRED_STATE) { LogUtils.i(LOGTAG, "Skip displaying alarm for instance: %s", mAlarmInstance); finish(); return; } LogUtils.i(LOGTAG, "Displaying alarm for instance: %s", mAlarmInstance); // Get the volume/camera button behavior setting mVolumeBehavior = Utils.getDefaultSharedPreferences(this).getString(SettingsActivity.KEY_VOLUME_BUTTONS, SettingsActivity.DEFAULT_VOLUME_BEHAVIOR); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON); // Hide navigation bar to minimize accidental tap on Home key hideNavigationBar(); // Close dialogs and window shade, so this is fully visible sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); // In order to allow tablets to freely rotate and phones to stick // with "nosensor" (use default device orientation) we have to have // the manifest start with an orientation of unspecified" and only limit // to "nosensor" for phones. Otherwise we get behavior like in b/8728671 // where tablets start off in their default orientation and then are // able to freely rotate. if (!getResources().getBoolean(R.bool.config_rotateAlarmAlert)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE); setContentView(R.layout.alarm_activity); mAlertView = (ViewGroup) findViewById(R.id.alert); mAlertTitleView = (TextView) mAlertView.findViewById(R.id.alert_title); mAlertInfoView = (TextView) mAlertView.findViewById(R.id.alert_info); mContentView = (ViewGroup) findViewById(R.id.content); mAlarmButton = (ImageView) mContentView.findViewById(R.id.alarm); mSnoozeButton = (ImageView) mContentView.findViewById(R.id.snooze); mDismissButton = (ImageView) mContentView.findViewById(R.id.dismiss); mHintView = (TextView) mContentView.findViewById(R.id.hint); final TextView titleView = (TextView) mContentView.findViewById(R.id.title); final TextClock digitalClock = (TextClock) mContentView.findViewById(R.id.digital_clock); final CircleView pulseView = (CircleView) mContentView.findViewById(R.id.pulse); titleView.setText(mAlarmInstance.getLabelOrDefault(this)); Utils.setTimeFormat(this, digitalClock); mCurrentHourColor = Utils.getCurrentHourColor(); getWindow().setBackgroundDrawable(new ColorDrawable(mCurrentHourColor)); mAlarmButton.setOnTouchListener(this); mSnoozeButton.setOnClickListener(this); mDismissButton.setOnClickListener(this); mAlarmAnimator = AnimatorUtils.getScaleAnimator(mAlarmButton, 1.0f, 0.0f); mSnoozeAnimator = getButtonAnimator(mSnoozeButton, Color.WHITE); mDismissAnimator = getButtonAnimator(mDismissButton, mCurrentHourColor); mPulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView, PropertyValuesHolder.ofFloat(CircleView.RADIUS, 0.0f, pulseView.getRadius()), PropertyValuesHolder.ofObject(CircleView.FILL_COLOR, AnimatorUtils.ARGB_EVALUATOR, ColorUtils.setAlphaComponent(pulseView.getFillColor(), 0))); mPulseAnimator.setDuration(PULSE_DURATION_MILLIS); mPulseAnimator.setInterpolator(PULSE_INTERPOLATOR); mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); mPulseAnimator.start(); }
From source file:com.onyx.deskclock.deskclock.alarms.AlarmActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final long instanceId = AlarmInstance.getId(getIntent().getData()); mAlarmInstance = AlarmInstance.getInstance(getContentResolver(), instanceId); if (mAlarmInstance == null) { // The alarm was deleted before the activity got created, so just finish() LogUtils.e(LOGTAG, "Error displaying alarm for intent: %s", getIntent()); finish();/*from ww w. j a v a2 s .c o m*/ return; } else if (mAlarmInstance.mAlarmState != AlarmInstance.FIRED_STATE) { LogUtils.i(LOGTAG, "Skip displaying alarm for instance: %s", mAlarmInstance); finish(); return; } LogUtils.i(LOGTAG, "Displaying alarm for instance: %s", mAlarmInstance); // Get the volume/camera button behavior setting mVolumeBehavior = PreferenceManager.getDefaultSharedPreferences(this) .getString(SettingsActivity.KEY_VOLUME_BUTTONS, SettingsActivity.DEFAULT_VOLUME_BEHAVIOR); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON); // Hide navigation bar to minimize accidental tap on Home key hideNavigationBar(); // Close dialogs and window shade, so this is fully visible sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); // In order to allow tablets to freely rotate and phones to stick // with "nosensor" (use default device orientation) we have to have // the manifest start with an orientation of unspecified" and only limit // to "nosensor" for phones. Otherwise we get behavior like in b/8728671 // where tablets start off in their default orientation and then are // able to freely rotate. if (!getResources().getBoolean(R.bool.config_rotateAlarmAlert)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE); setContentView(R.layout.alarm_activity); mAlertView = (ViewGroup) findViewById(R.id.alert); mAlertTitleView = (TextView) mAlertView.findViewById(R.id.alert_title); mAlertInfoView = (TextView) mAlertView.findViewById(R.id.alert_info); mContentView = (ViewGroup) findViewById(R.id.content); mAlarmButton = (ImageView) mContentView.findViewById(R.id.alarm); mSnoozeButton = (ImageView) mContentView.findViewById(R.id.snooze); mDismissButton = (ImageView) mContentView.findViewById(R.id.dismiss); mHintView = (TextView) mContentView.findViewById(R.id.hint); final TextView titleView = (TextView) mContentView.findViewById(R.id.title); // final TextClock digitalClock = (TextClock) mContentView.findViewById(R.id.digital_clock); final TextTime digitalClock = (TextTime) mContentView.findViewById(R.id.digital_clock); final CircleView pulseView = (CircleView) mContentView.findViewById(R.id.pulse); titleView.setText(mAlarmInstance.getLabelOrDefault(this)); Utils.setTimeFormat(this, digitalClock); mCurrentHourColor = Utils.getCurrentHourColor(); getWindow().setBackgroundDrawable(new ColorDrawable(mCurrentHourColor)); mAlarmButton.setOnTouchListener(this); mSnoozeButton.setOnClickListener(this); mDismissButton.setOnClickListener(this); mAlarmAnimator = AnimatorUtils.getScaleAnimator(mAlarmButton, 1.0f, 0.0f); mSnoozeAnimator = getButtonAnimator(mSnoozeButton, Color.WHITE); mDismissAnimator = getButtonAnimator(mDismissButton, mCurrentHourColor); mPulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView, PropertyValuesHolder.ofFloat(CircleView.RADIUS, 0.0f, pulseView.getRadius()), PropertyValuesHolder.ofObject(CircleView.FILL_COLOR, AnimatorUtils.ARGB_EVALUATOR, ColorUtils.setAlphaComponent(pulseView.getFillColor(), 0))); mPulseAnimator.setDuration(PULSE_DURATION_MILLIS); mPulseAnimator.setInterpolator(PULSE_INTERPOLATOR); mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); mPulseAnimator.start(); }
From source file:com.stasbar.knowyourself.alarms.AlarmActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final long instanceId = AlarmInstance.getId(getIntent().getData()); mAlarmInstance = AlarmInstance.getInstance(getContentResolver(), instanceId); if (mAlarmInstance == null) { // The alarm was deleted before the activity got created, so just finish() LOGGER.e("Error displaying alarm for intent: %s", getIntent()); finish();/*from ww w .j a v a 2s . c o m*/ return; } else if (mAlarmInstance.mAlarmState != AlarmInstance.FIRED_STATE) { LOGGER.i("Skip displaying alarm for instance: %s", mAlarmInstance); finish(); return; } LOGGER.i("Displaying alarm for instance: %s", mAlarmInstance); // Get the volume/camera button behavior setting mVolumeBehavior = Utils.getDefaultSharedPreferences(this).getString(SettingsActivity.KEY_VOLUME_BUTTONS, SettingsActivity.DEFAULT_VOLUME_BEHAVIOR); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON); // Hide navigation bar to minimize accidental tap on Home key hideNavigationBar(); // Close dialogs and window shade, so this is fully visible sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); // Honor rotation on tablets; fix the orientation on phones. if (!getResources().getBoolean(R.bool.config_rotateAlarmAlert)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE); setContentView(R.layout.alarm_activity); mAlertView = (ViewGroup) findViewById(R.id.alert); mAlertTitleView = (TextView) mAlertView.findViewById(R.id.alert_title); mAlertInfoView = (TextView) mAlertView.findViewById(R.id.alert_info); mContentView = (ViewGroup) findViewById(R.id.content); mAlarmButton = (ImageView) mContentView.findViewById(R.id.alarm); mSnoozeButton = (ImageView) mContentView.findViewById(R.id.snooze); mDismissButton = (ImageView) mContentView.findViewById(R.id.dismiss); mHintView = (TextView) mContentView.findViewById(R.id.hint); final TextView titleView = (TextView) mContentView.findViewById(R.id.title); final TextClock digitalClock = (TextClock) mContentView.findViewById(R.id.digital_clock); final CircleView pulseView = (CircleView) mContentView.findViewById(R.id.pulse); titleView.setText(mAlarmInstance.getLabelOrDefault(this)); Utils.setTimeFormat(digitalClock); mCurrentHourColor = UiDataModel.getUiDataModel().getWindowBackgroundColor(); getWindow().setBackgroundDrawable(new ColorDrawable(mCurrentHourColor)); mAlarmButton.setOnTouchListener(this); mSnoozeButton.setOnClickListener(this); mDismissButton.setOnClickListener(this); mAlarmAnimator = AnimatorUtils.getScaleAnimator(mAlarmButton, 1.0f, 0.0f); mSnoozeAnimator = getButtonAnimator(mSnoozeButton, Color.WHITE); mDismissAnimator = getButtonAnimator(mDismissButton, mCurrentHourColor); mPulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView, PropertyValuesHolder.ofFloat(CircleView.RADIUS, 0.0f, pulseView.getRadius()), PropertyValuesHolder.ofObject(CircleView.FILL_COLOR, AnimatorUtils.ARGB_EVALUATOR, ColorUtils.setAlphaComponent(pulseView.getFillColor(), 0))); mPulseAnimator.setDuration(PULSE_DURATION_MILLIS); mPulseAnimator.setInterpolator(PULSE_INTERPOLATOR); mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); mPulseAnimator.start(); }
From source file:com.androidinspain.deskclock.alarms.AlarmActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setVolumeControlStream(AudioManager.STREAM_ALARM); final long instanceId = AlarmInstance.getId(getIntent().getData()); mAlarmInstance = AlarmInstance.getInstance(getContentResolver(), instanceId); if (mAlarmInstance == null) { // The alarm was deleted before the activity got created, so just finish() LOGGER.e("Error displaying alarm for intent: %s", getIntent()); finish();// w w w. j av a 2s . c o m return; } else if (mAlarmInstance.mAlarmState != AlarmInstance.FIRED_STATE) { LOGGER.i("Skip displaying alarm for instance: %s", mAlarmInstance); finish(); return; } LOGGER.i("Displaying alarm for instance: %s", mAlarmInstance); // Get the volume/camera button behavior setting mVolumeBehavior = DataModel.getDataModel().getAlarmVolumeButtonBehavior(); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON); // Hide navigation bar to minimize accidental tap on Home key hideNavigationBar(); // Close dialogs and window shade, so this is fully visible sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); // Honor rotation on tablets; fix the orientation on phones. if (!getResources().getBoolean(com.androidinspain.deskclock.R.bool.rotateAlarmAlert)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE); setContentView(com.androidinspain.deskclock.R.layout.alarm_activity); mAlertView = (ViewGroup) findViewById(com.androidinspain.deskclock.R.id.alert); mAlertTitleView = (TextView) mAlertView.findViewById(com.androidinspain.deskclock.R.id.alert_title); mAlertInfoView = (TextView) mAlertView.findViewById(com.androidinspain.deskclock.R.id.alert_info); mContentView = (ViewGroup) findViewById(com.androidinspain.deskclock.R.id.content); mAlarmButton = (ImageView) mContentView.findViewById(com.androidinspain.deskclock.R.id.alarm); mSnoozeButton = (ImageView) mContentView.findViewById(com.androidinspain.deskclock.R.id.snooze); mDismissButton = (ImageView) mContentView.findViewById(com.androidinspain.deskclock.R.id.dismiss); mHintView = (TextView) mContentView.findViewById(com.androidinspain.deskclock.R.id.hint); final TextView titleView = (TextView) mContentView.findViewById(com.androidinspain.deskclock.R.id.title); final TextClock digitalClock = (TextClock) mContentView .findViewById(com.androidinspain.deskclock.R.id.digital_clock); final CircleView pulseView = (CircleView) mContentView .findViewById(com.androidinspain.deskclock.R.id.pulse); titleView.setText(mAlarmInstance.getLabelOrDefault(this)); Utils.setTimeFormat(digitalClock, false); mCurrentHourColor = ThemeUtils.resolveColor(this, android.R.attr.windowBackground); getWindow().setBackgroundDrawable(new ColorDrawable(mCurrentHourColor)); mAlarmButton.setOnTouchListener(this); mSnoozeButton.setOnClickListener(this); mDismissButton.setOnClickListener(this); mAlarmAnimator = AnimatorUtils.getScaleAnimator(mAlarmButton, 1.0f, 0.0f); mSnoozeAnimator = getButtonAnimator(mSnoozeButton, Color.WHITE); mDismissAnimator = getButtonAnimator(mDismissButton, mCurrentHourColor); mPulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView, PropertyValuesHolder.ofFloat(CircleView.RADIUS, 0.0f, pulseView.getRadius()), PropertyValuesHolder.ofObject(CircleView.FILL_COLOR, AnimatorUtils.ARGB_EVALUATOR, ColorUtils.setAlphaComponent(pulseView.getFillColor(), 0))); mPulseAnimator.setDuration(PULSE_DURATION_MILLIS); mPulseAnimator.setInterpolator(PULSE_INTERPOLATOR); mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); mPulseAnimator.start(); }
From source file:com.wizardsofm.deskclock.alarms.AlarmActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final long instanceId = AlarmInstance.getId(getIntent().getData()); mAlarmInstance = AlarmInstance.getInstance(getContentResolver(), instanceId); if (mAlarmInstance == null) { // The alarm was deleted before the activity got created, so just finish() LOGGER.e("Error displaying alarm for intent: %s", getIntent()); finish();//ww w .j a v a 2s . c o m return; } else if (mAlarmInstance.mAlarmState != AlarmInstance.FIRED_STATE) { LOGGER.i("Skip displaying alarm for instance: %s", mAlarmInstance); finish(); return; } LOGGER.i("Displaying alarm for instance: %s", mAlarmInstance); // Get the volume/camera button behavior setting mVolumeBehavior = Utils.getDefaultSharedPreferences(this).getString(SettingsActivity.KEY_VOLUME_BUTTONS, SettingsActivity.DEFAULT_VOLUME_BEHAVIOR); getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED | FLAG_DISMISS_KEYGUARD | FLAG_KEEP_SCREEN_ON | FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON); // Hide navigation bar to minimize accidental tap on Home key hideNavigationBar(); // Close dialogs and window shade, so this is fully visible sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); // Honor rotation on tablets; fix the orientation on phones. if (!getResources().getBoolean(R.bool.config_rotateAlarmAlert)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE); setContentView(R.layout.alarm_activity); mAlertView = (ViewGroup) findViewById(R.id.alert); mAlertTitleView = (TextView) mAlertView.findViewById(R.id.alert_title); mAlertInfoView = (TextView) mAlertView.findViewById(R.id.alert_info); mContentView = (ViewGroup) findViewById(R.id.content); mAlarmButton = (ImageView) mContentView.findViewById(R.id.alarm); mSnoozeButton = (ImageView) mContentView.findViewById(R.id.snooze); mDismissButton = (ImageView) mContentView.findViewById(R.id.dismiss); mHintView = (TextView) mContentView.findViewById(R.id.hint); final TextView titleView = (TextView) mContentView.findViewById(R.id.title); final TextClock digitalClock = (TextClock) mContentView.findViewById(R.id.digital_clock); final CircleView pulseView = (CircleView) mContentView.findViewById(R.id.pulse); // PowerManager pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE); // PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG"); // wakeLock.acquire(); // // // // KeyguardManager keyguardManager = (KeyguardManager) getApplicationContext().getSystemService(Context.KEYGUARD_SERVICE); // KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("TAG"); // keyguardLock.disableKeyguard(); titleView.setText(mAlarmInstance.getLabelOrDefault(this)); Utils.setTimeFormat(digitalClock); mCurrentHourColor = UiDataModel.getUiDataModel().getWindowBackgroundColor(); getWindow().setBackgroundDrawable(new ColorDrawable(mCurrentHourColor)); mAlarmButton.setOnTouchListener(this); mSnoozeButton.setOnClickListener(this); mDismissButton.setOnClickListener(this); mAlarmAnimator = AnimatorUtils.getScaleAnimator(mAlarmButton, 1.0f, 0.0f); mSnoozeAnimator = getButtonAnimator(mSnoozeButton, Color.WHITE); mDismissAnimator = getButtonAnimator(mDismissButton, mCurrentHourColor); mPulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView, PropertyValuesHolder.ofFloat(CircleView.RADIUS, 0.0f, pulseView.getRadius()), PropertyValuesHolder.ofObject(CircleView.FILL_COLOR, AnimatorUtils.ARGB_EVALUATOR, ColorUtils.setAlphaComponent(pulseView.getFillColor(), 0))); mPulseAnimator.setDuration(PULSE_DURATION_MILLIS); mPulseAnimator.setInterpolator(PULSE_INTERPOLATOR); mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); mPulseAnimator.start(); if (DataModel.getDataModel().getSnoozeByVoice()) { startListening(); } // if (DataModel.getDataModel().getSnoozeByVoice()) { // thisContext = this; // Thread t1 = new Thread(new Runnable() { // public void run() { // mSpeechRecognizerManager = SpeechRecognizerManager.getInstance(thisContext); //new SpeechRecognizerManager(thisContext); // } // }); // t1.start(); // // } }
From source file:com.deepak.myclock.alarms.AlarmNotifications.java
public static void showAlarmNotification(Context context, AlarmInstance instance) { Log.v("Displaying alarm notification for alarm instance: " + instance.mId); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // Close dialogs and window shade, so this will display context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); Resources resources = context.getResources(); NotificationCompat.Builder notification = new NotificationCompat.Builder(context) .setContentTitle(instance.getLabelOrDefault(context)) .setContentText(AlarmUtils.getFormattedTime(context, instance.getAlarmTime())) .setSmallIcon(R.drawable.stat_notify_alarm).setOngoing(true).setAutoCancel(false).setWhen(0); // Setup Snooze Action Intent snoozeIntent = AlarmStateManager.createStateChangeIntent(context, "SNOOZE_TAG", instance, AlarmInstance.SNOOZE_STATE); PendingIntent snoozePendingIntent = PendingIntent.getBroadcast(context, instance.hashCode(), snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(R.drawable.stat_notify_alarm, resources.getString(R.string.alarm_alert_snooze_text), snoozePendingIntent);/* w w w . j av a 2s. co m*/ // Setup Dismiss Action Intent dismissIntent = AlarmStateManager.createStateChangeIntent(context, "DISMISS_TAG", instance, AlarmInstance.DISMISSED_STATE); PendingIntent dismissPendingIntent = PendingIntent.getBroadcast(context, instance.hashCode(), dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(android.R.drawable.ic_menu_close_clear_cancel, resources.getString(R.string.alarm_alert_dismiss_text), dismissPendingIntent); // Setup Content Action Intent contentIntent = AlarmInstance.createIntent(context, AlarmActivity.class, instance.mId); notification.setContentIntent(PendingIntent.getActivity(context, instance.hashCode(), contentIntent, PendingIntent.FLAG_UPDATE_CURRENT)); // Setup fullscreen intent /*Intent fullScreenIntent = AlarmInstance.createIntent(context, AlarmActivity.class, instance.mId); // set action, so we can be different then content pending intent fullScreenIntent.setAction("fullscreen_activity"); fullScreenIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); notification.setFullScreenIntent(PendingIntent.getActivity(context, instance.hashCode(), fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT), true);*/ notification.setPriority(NotificationCompat.PRIORITY_MAX); nm.cancel(instance.hashCode()); nm.notify(instance.hashCode(), notification.build()); }
From source file:com.klinker.deskclock.alarms.AlarmNotifications.java
public static void showAlarmNotification(Context context, AlarmInstance instance) { Log.v("Displaying alarm notification for alarm instance: " + instance.mId); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // Close dialogs and window shade, so this will display context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); Resources resources = context.getResources(); NotificationCompat.Builder notification = new NotificationCompat.Builder(context) .setContentTitle(instance.getLabelOrDefault(context)) .setContentText(AlarmUtils.getFormattedTime(context, instance.getAlarmTime())) .setSmallIcon(R.drawable.stat_notify_alarm).setOngoing(true).setAutoCancel(false).setWhen(0); // Setup Snooze Action Intent snoozeIntent = AlarmStateManager.createStateChangeIntent(context, "SNOOZE_TAG", instance, AlarmInstance.SNOOZE_STATE); PendingIntent snoozePendingIntent = PendingIntent.getBroadcast(context, instance.hashCode(), snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(R.drawable.stat_notify_alarm, resources.getString(R.string.alarm_alert_snooze_text), snoozePendingIntent);//from w w w .j a v a2s . com // Setup Dismiss Action Intent dismissIntent = AlarmStateManager.createStateChangeIntent(context, "DISMISS_TAG", instance, AlarmInstance.DISMISSED_STATE); PendingIntent dismissPendingIntent = PendingIntent.getBroadcast(context, instance.hashCode(), dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(android.R.drawable.ic_menu_close_clear_cancel, resources.getString(R.string.alarm_alert_dismiss_text), dismissPendingIntent); // Setup Content Action Intent contentIntent = AlarmInstance.createIntent(context, AlarmActivity.class, instance.mId); notification.setContentIntent(PendingIntent.getActivity(context, instance.hashCode(), contentIntent, PendingIntent.FLAG_UPDATE_CURRENT)); // Setup fullscreen intent Intent fullScreenIntent = AlarmInstance.createIntent(context, AlarmActivity.class, instance.mId); // set action, so we can be different then content pending intent fullScreenIntent.setAction("fullscreen_activity"); fullScreenIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); notification.setFullScreenIntent(PendingIntent.getActivity(context, instance.hashCode(), fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT), true); notification.setPriority(NotificationCompat.PRIORITY_MAX); nm.cancel(instance.hashCode()); nm.notify(instance.hashCode(), notification.build()); }
From source file:se.oort.clockify.alarms.AlarmNotifications.java
public static void showAlarmNotification(Context context, AlarmInstance instance) { Log.v(LOG_TAG, "Displaying alarm notification for alarm instance: " + instance.mId); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // Close dialogs and window shade, so this will display context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); Resources resources = context.getResources(); NotificationCompat.Builder notification = new NotificationCompat.Builder(context) .setContentTitle(instance.getLabelOrDefault(context)) .setContentText(AlarmUtils.getFormattedTime(context, instance.getAlarmTime())) .setSmallIcon(R.drawable.stat_notify_alarm).setOngoing(true).setAutoCancel(false).setWhen(0); // Setup Snooze Action Intent snoozeIntent = AlarmStateManager.createStateChangeIntent(context, "SNOOZE_TAG", instance, AlarmInstance.SNOOZE_STATE); PendingIntent snoozePendingIntent = PendingIntent.getBroadcast(context, instance.hashCode(), snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(R.drawable.stat_notify_alarm, resources.getString(R.string.alarm_alert_snooze_text), snoozePendingIntent);// w w w. ja v a 2 s. c o m // Setup Dismiss Action Intent dismissIntent = AlarmStateManager.createStateChangeIntent(context, "DISMISS_TAG", instance, AlarmInstance.DISMISSED_STATE); PendingIntent dismissPendingIntent = PendingIntent.getBroadcast(context, instance.hashCode(), dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(android.R.drawable.ic_menu_close_clear_cancel, resources.getString(R.string.alarm_alert_dismiss_text), dismissPendingIntent); // Setup Content Action Intent contentIntent = AlarmInstance.createIntent(context, AlarmActivity.class, instance.mId); notification.setContentIntent(PendingIntent.getActivity(context, instance.hashCode(), contentIntent, PendingIntent.FLAG_UPDATE_CURRENT)); // Setup fullscreen intent Intent fullScreenIntent = AlarmInstance.createIntent(context, AlarmActivity.class, instance.mId); // set action, so we can be different then content pending intent fullScreenIntent.setAction("fullscreen_activity"); fullScreenIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); notification.setFullScreenIntent(PendingIntent.getActivity(context, instance.hashCode(), fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT), true); notification.setPriority(NotificationCompat.PRIORITY_MAX); nm.cancel(instance.hashCode()); nm.notify(instance.hashCode(), notification.build()); }
From source file:com.embeddedlog.LightUpDroid.alarms.AlarmNotifications.java
public static void showAlarmNotification(Context context, AlarmInstance instance) { Log.v("Displaying alarm notification for alarm instance: " + instance.mId); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // Close dialogs and window shade, so this will display context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); Resources resources = context.getResources(); NotificationCompat.Builder notification = new NotificationCompat.Builder(context) .setContentTitle(instance.getLabelOrDefault(context)) .setContentText(AlarmUtils.getFormattedTime(context, instance.getAlarmTime())) .setSmallIcon(R.drawable.stat_notify_alarm).setOngoing(true).setAutoCancel(false) .setDefaults(NotificationCompat.DEFAULT_LIGHTS).setWhen(0) .setCategory(NotificationCompat.CATEGORY_ALARM); // Setup Snooze Action Intent snoozeIntent = AlarmStateManager.createStateChangeIntent(context, "SNOOZE_TAG", instance, AlarmInstance.SNOOZE_STATE); PendingIntent snoozePendingIntent = PendingIntent.getBroadcast(context, instance.hashCode(), snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(R.drawable.stat_notify_alarm, resources.getString(R.string.alarm_alert_snooze_text), snoozePendingIntent);//from ww w .j av a 2s. c o m // Setup Dismiss Action Intent dismissIntent = AlarmStateManager.createStateChangeIntent(context, "DISMISS_TAG", instance, AlarmInstance.DISMISSED_STATE); PendingIntent dismissPendingIntent = PendingIntent.getBroadcast(context, instance.hashCode(), dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(android.R.drawable.ic_menu_close_clear_cancel, resources.getString(R.string.alarm_alert_dismiss_text), dismissPendingIntent); // Setup Content Action Intent contentIntent = AlarmInstance.createIntent(context, AlarmActivity.class, instance.mId); notification.setContentIntent(PendingIntent.getActivity(context, instance.hashCode(), contentIntent, PendingIntent.FLAG_UPDATE_CURRENT)); // Setup fullscreen intent Intent fullScreenIntent = AlarmInstance.createIntent(context, AlarmActivity.class, instance.mId); // set action, so we can be different then content pending intent fullScreenIntent.setAction("fullscreen_activity"); fullScreenIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); notification.setFullScreenIntent(PendingIntent.getActivity(context, instance.hashCode(), fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT), true); notification.setPriority(NotificationCompat.PRIORITY_MAX); nm.cancel(instance.hashCode()); nm.notify(instance.hashCode(), notification.build()); }