Example usage for android.content Intent ACTION_CLOSE_SYSTEM_DIALOGS

List of usage examples for android.content Intent ACTION_CLOSE_SYSTEM_DIALOGS

Introduction

In this page you can find the example usage for android.content Intent ACTION_CLOSE_SYSTEM_DIALOGS.

Prototype

String ACTION_CLOSE_SYSTEM_DIALOGS

To view the source code for android.content Intent ACTION_CLOSE_SYSTEM_DIALOGS.

Click Source Link

Document

Broadcast Action: This is broadcast when a user action should request a temporary system dialog to dismiss.

Usage

From source file:com.onesignal.NotificationOpenedProcessor.java

public static void processFromActivity(Context inContext, Intent inIntent) {
    // Pressed an action button, need to clear the notification and close the notification area manually.
    if (inIntent.getBooleanExtra("action_button", false)) {
        NotificationManagerCompat.from(inContext).cancel(inIntent.getIntExtra("notificationId", 0));
        inContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
    }/*w w  w.  ja v  a  2  s .co  m*/

    processIntent(inContext, inIntent);
}

From source file:saphion.fragment.alarm.alert.AlarmAlertReceiver.java

@SuppressWarnings("deprecation")
@Override//from ww w.j av  a2s.co m
public void onReceive(final Context context, final Intent intent) {
    String action = intent.getAction();
    int pos = intent.getIntExtra(PreferenceHelper.BAT_VALS, 0);
    level = intent.getIntExtra(PreferenceHelper.CURR_RING, 72);

    //Log.Toast(context, level + " in receiver", Toast.LENGTH_LONG);
    // int id = intent.getIntExtra(Intents.EXTRA_ID, -1);

    if (action.equals(Intents.ALARM_ALERT_ACTION)) {
        /* Close dialogs and window shade */
        Intent closeDialogs = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
        context.sendBroadcast(closeDialogs);

        // Decide which activity to start based on the state of the
        // keyguard.
        /*
         * KeyguardManager km = (KeyguardManager)
         * context.getSystemService(Context.KEYGUARD_SERVICE); if
         * (km.inKeyguardRestrictedInputMode()) { // Use the full screen
         * activity for security. c = AlarmAlertFullScreen.class; }
         */

        // Trigger a notification that, when clicked, will show the alarm
        // alert
        // dialog. No need to check for fullscreen since this will always be
        // launched from a user action.

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
            Intent notify = new Intent(context, saphion.fragments.alarm.AlarmAlert.class);
            notify.putExtra(PreferenceHelper.BAT_VALS, pos);
            PendingIntent pendingNotify = PendingIntent.getActivity(context, ID, notify, 0);

            // Alarm alarm = AlarmsManager.getAlarmsManager().getAlarm(id);
            Notification n = new Notification(R.drawable.stat_notify_alarm, "abc", System.currentTimeMillis());
            n.setLatestEventInfo(context, "Battery Alarm", "Battery Level is " + level, pendingNotify);
            n.flags |= Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_ONGOING_EVENT;
            n.defaults |= Notification.DEFAULT_LIGHTS;

            // NEW: Embed the full-screen UI here. The notification manager
            // will // take care of displaying it if it's OK to do so.
            Intent alarmAlert = new Intent(context, saphion.fragments.alarm.AlarmAlert.class);
            alarmAlert.putExtra(PreferenceHelper.CURR_RING, level);
            alarmAlert.putExtra(PreferenceHelper.BAT_VALS, pos);
            alarmAlert.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION);
            n.fullScreenIntent = PendingIntent.getActivity(context, ID, alarmAlert, 0);

            // Send the notification using the alarm id to easily identify
            // the // correct notification.
            NotificationManager nm = (NotificationManager) context
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            // Log.Toast(context, "Recieved", Toast.LENGTH_LONG);
            // mNotificationManager.notify(ID, builder.build());
            nm.notify(ID, n);
        } else {
            // Log.Toast(context, "Recieved", Toast.LENGTH_LONG);
            newMethod(context, pos);
        }

    } else if (action.equals(Intents.ALARM_DISMISS_ACTION)) {
        NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        nm.cancel(ID);
    }
}

From source file:cw.kop.autobackground.files.FileHandler.java

public static void cancel(Context appContext) {
    if (downloadThread != null) {
        downloadThread.interrupt();//from ww w .  j a v  a  2  s.  c  o  m
        Toast.makeText(appContext, "Stopping download...", Toast.LENGTH_SHORT).show();
        Intent closeDrawer = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
        appContext.sendBroadcast(closeDrawer);
        Intent resetDownloadIntent = new Intent(FileHandler.DOWNLOAD_TERMINATED);
        LocalBroadcastManager.getInstance(appContext).sendBroadcast(resetDownloadIntent);
    }
    isDownloading = false;
}

From source file:com.better.alarm.presenter.alert.AlarmAlertReceiver.java

private void onAlert(Alarm alarm) {
    int id = alarm.getId();

    /* Close dialogs and window shade */
    Intent closeDialogs = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    mContext.sendBroadcast(closeDialogs);

    // Decide which activity to start based on the state of the
    // keyguard - is the screen locked or not.
    Class<? extends AlarmAlertFullScreen> c = AlarmAlert.class;
    KeyguardManager km = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
    if (km.inKeyguardRestrictedInputMode()) {
        // Use the full screen activity to unlock the screen.
        c = AlarmAlertFullScreen.class;
    }/*from  www.  j  a  v a2  s  .  co m*/

    // Trigger a notification that, when clicked, will show the alarm
    // alert dialog. No need to check for fullscreen since this will always
    // be launched from a user action.
    Intent notify = new Intent(mContext, c);
    notify.putExtra(Intents.EXTRA_ID, id);
    PendingIntent pendingNotify = PendingIntent.getActivity(mContext, id, notify, 0);
    PendingIntent pendingSnooze = PresentationToModelIntents.createPendingIntent(mContext,
            PresentationToModelIntents.ACTION_REQUEST_SNOOZE, id);
    PendingIntent pendingDismiss = PresentationToModelIntents.createPendingIntent(mContext,
            PresentationToModelIntents.ACTION_REQUEST_DISMISS, id);

    //@formatter:off
    Notification status = new NotificationCompat.Builder(mContext)
            .setContentTitle(alarm.getLabelOrDefault(mContext))
            .setContentText(mContext.getString(R.string.alarm_notify_text))
            .setSmallIcon(R.drawable.stat_notify_alarm)
            // setFullScreenIntent to show the user AlarmAlert dialog at the same time 
            // when the Notification Bar was created.
            .setFullScreenIntent(pendingNotify, true)
            // setContentIntent to show the user AlarmAlert dialog  
            // when he will click on the Notification Bar.
            .setContentIntent(pendingNotify).setOngoing(true)
            .addAction(R.drawable.ic_action_snooze, mContext.getString(R.string.alarm_alert_snooze_text),
                    pendingSnooze)
            .addAction(R.drawable.ic_action_dismiss, mContext.getString(R.string.alarm_alert_dismiss_text),
                    pendingDismiss)
            .setDefaults(Notification.DEFAULT_LIGHTS).build();
    //@formatter:on

    // Send the notification using the alarm id to easily identify the
    // correct notification.
    nm.notify(id, status);
}

From source file:com.mattprecious.prioritysms.receiver.AlarmReceiver.java

private void doAlarm(Context context, BaseProfile profile, String number, String message) {
    // Maintain a cpu wake lock until the AlarmActivity and AlarmService can
    // pick it up.
    AlarmAlertWakeLock.acquireCpuWakeLock(context);

    /* Close dialogs and window shade */
    Intent closeDialogs = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    context.sendBroadcast(closeDialogs);

    // Play the alarm alert and vibrate the device.
    Intent playAlarm = new Intent(Intents.ACTION_ALERT);
    playAlarm.putExtra(Intents.EXTRA_PROFILE, profile);
    context.startService(playAlarm);/*from   ww w.j  a  v  a  2  s.  c  o m*/

    Intent dismissIntent = new Intent(Intents.ACTION_DISMISS);
    dismissIntent.putExtra(Intents.EXTRA_PROFILE, profile);
    PendingIntent pendingDismiss = PendingIntent.getBroadcast(context, profile.getId(), dismissIntent, 0);

    Intent replyIntent = new Intent(Intents.ACTION_REPLY);
    replyIntent.putExtra(Intents.EXTRA_PROFILE, profile);
    PendingIntent pendingReply = PendingIntent.getBroadcast(context, profile.getId(), replyIntent, 0);

    Intent callIntent = new Intent(Intents.ACTION_CALL);
    callIntent.putExtra(Intents.EXTRA_PROFILE, profile);
    PendingIntent pendingCall = PendingIntent.getBroadcast(context, profile.getId(), callIntent, 0);

    Intent activityIntent = new Intent(context, AlarmActivity.class);
    activityIntent.setAction(String.valueOf(System.currentTimeMillis()));
    activityIntent.putExtra(Intents.EXTRA_PROFILE, profile);
    activityIntent.putExtra(Intents.EXTRA_NUMBER, number);
    activityIntent.putExtra(Intents.EXTRA_MESSAGE, message);
    activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION);
    PendingIntent pendingActivity = PendingIntent.getActivity(context, profile.getId(), activityIntent, 0);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setContentTitle(profile.getName()).setSmallIcon(R.drawable.ic_stat_alarm).setAutoCancel(false)
            .setPriority(NotificationCompat.PRIORITY_MAX).setDefaults(Notification.DEFAULT_LIGHTS)
            .addAction(android.R.drawable.ic_menu_close_clear_cancel,
                    context.getString(R.string.notif_action_dismiss), pendingDismiss)
            .addAction(android.R.drawable.ic_menu_send, context.getString(R.string.notif_action_reply),
                    pendingReply)
            .addAction(android.R.drawable.ic_menu_call, context.getString(R.string.notif_action_call),
                    pendingCall)
            .setFullScreenIntent(pendingActivity, true).setContentIntent(pendingActivity)
            .setDeleteIntent(pendingDismiss);

    Notification notif = builder.build();

    // Send the notification using the alarm id to easily identify the
    // correct notification.
    NotificationManager nm = getNotificationManager(context);
    nm.notify(profile.getId(), notif);

    // full screen intent doesn't do anything pre-honeycomb
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        context.startActivity(activityIntent);
    }
}

From source file:org.messic.android.smartphone.notifications.MessicPlayerNotification.java

private void registerBroadcastActions() {
    IntentFilter filter = new IntentFilter();
    filter.addAction(ACTION_BACK);//from ww  w .  ja va  2 s .c  o  m
    filter.addAction(ACTION_PLAY);
    filter.addAction(ACTION_PAUSE);
    filter.addAction(ACTION_NEXT);
    filter.addAction(ACTION_CLOSE);
    filter.addAction(ACTION_ALBUM);
    BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals(ACTION_BACK)) {
                player.prevSong();
            } else if (intent.getAction().equals(ACTION_PLAY)) {
                player.resumeSong();
            } else if (intent.getAction().equals(ACTION_PAUSE)) {
                player.pauseSong();
            } else if (intent.getAction().equals(ACTION_NEXT)) {
                player.nextSong();
            } else if (intent.getAction().equals(ACTION_CLOSE)) {
                service.stopForeground(true);
                service.unregisterReceiver(this);
                mNotificationManager.cancel(ONGOING_NOTIFICATION_ID);

                ump.clearAndStopAll();

                Intent ssa = new Intent(MessicPlayerNotification.this.service, LoginActivity.class);
                ssa.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                ssa.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                MessicPlayerNotification.this.service.getApplication().startActivity(ssa);

            } else if (intent.getAction().equals(ACTION_ALBUM)) {

                Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
                context.sendBroadcast(it);

                Observable<MDMAlbum> observable = getAlbum(player.getCurrentSong().getAlbum());

                observable.subscribeOn(Schedulers.io()).onBackpressureBuffer()
                        .observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<MDMAlbum>() {
                            @Override
                            public void call(MDMAlbum mdmAlbum) {
                                Intent ssa = new Intent(MessicPlayerNotification.this.service,
                                        AlbumInfoActivity.class);
                                ssa.putExtra(AlbumInfoActivity.EXTRA_ALBUM_SID, mdmAlbum);
                                ssa.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                ssa.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                                MessicPlayerNotification.this.service.getApplication().startActivity(ssa);
                            }
                        });

            }
        }
    };

    this.service.registerReceiver(receiver, filter);
}

From source file:com.linkbubble.MainService.java

@Override
public void onCreate() {

    mDestroyAllActivities = true;/*  w w w  .  j av a  2  s .  c  om*/
    mRestoreComplete = false;

    setTheme(Settings.get().getDarkThemeEnabled() ? R.style.MainServiceThemeDark
            : R.style.MainServiceThemeLight);

    super.onCreate();
    Fabric.with(this, new Crashlytics());
    CrashTracking.log("MainService.onCreate()");

    showDefaultNotification();

    Config.init(this);
    Settings.get().onOrientationChange();

    try {
        WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());
    } catch (RuntimeException exc) {
        CrashTracking.logHandledException(exc);
    }

    MainApplication.mDestroyActivitySharedLock = new Object();
    MainApplication.mActivityDestroyed = false;

    MainController.create(this, new MainController.EventHandler() {
        @Override
        public void onDestroy() {
            Settings.get().saveBubbleRestingPoint();
            stopSelf();
            CrashTracking.log("MainService.onCreate(): onDestroy()");
        }
    });

    //Intent i = new Intent();
    //i.setData(Uri.parse("https://t.co/uxMl3bWtMP"));
    //i.setData(Uri.parse("http://t.co/oOyu7GBZMU"));
    //i.setData(Uri.parse("http://goo.gl/abc57"));
    //i.setData(Uri.parse("https://bitly.com/QtQET"));
    //i.setData(Uri.parse("http://www.duckduckgo.com"));
    //openUrl("https://www.duckduckgo.com");
    //openUrl("http://www.duckduckgo.com", true);
    //openUrl("https://t.co/uxMl3bWtMP", true);

    IntentFilter filter = new IntentFilter();
    filter.addAction(BCAST_CONFIGCHANGED);
    registerReceiver(mBroadcastReceiver, filter);

    registerReceiver(mDialogReceiver, new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));

    filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addDataScheme("package");

    filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    filter.addAction(Intent.ACTION_USER_PRESENT);
    registerReceiver(mScreenReceiver, filter);

    MainApplication.registerForBus(this, this);
}

From source file:de.schildbach.wallet.service.InactivityNotificationService.java

private void handleDonate() {
    final Coin balance = wallet.getBalance(BalanceType.AVAILABLE_SPENDABLE);
    SendCoinsActivity.startDonate(this, balance, FeeCategory.ECONOMIC,
            Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    nm.cancel(Constants.NOTIFICATION_ID_INACTIVITY);
    sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
}

From source file:se.erichansander.retrotimer.TimerKlaxon.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    TinyTracelog.trace("4");

    // No intent, tell the system not to restart us.
    if (intent == null) {
        TinyTracelog.trace("4.e");
        stopSelf();//from  w w w.jav  a 2  s . c o  m
        return START_NOT_STICKY;
    }

    boolean ring = mPrefs.getBoolean(RetroTimer.PREF_RING_ON_ALARM, true);
    boolean vibrate = mPrefs.getBoolean(RetroTimer.PREF_VIBRATE_ON_ALARM, true);
    long timeoutMillis = mPrefs.getLong(RetroTimer.PREF_ALARM_TIMEOUT_MILLIS, 10 * 1000);
    mAlarmTime = intent.getLongExtra(RetroTimer.ALARM_TIME_EXTRA, 0);

    // Close dialogs and window shade
    sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));

    // Trigger a notification that, when clicked, will dismiss the alarm.
    Intent notify = new Intent(RetroTimer.ALARM_DISMISS_ACTION);
    PendingIntent pendingNotify = PendingIntent.getBroadcast(this, 0, notify, 0);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setContentIntent(pendingNotify)
            .setDefaults(Notification.DEFAULT_LIGHTS).setOngoing(true)
            .setSmallIcon(R.drawable.ic_stat_alarm_triggered)
            .setContentTitle(getString(R.string.notify_triggered_label))
            .setContentText(getString(R.string.notify_triggered_text));

    /*
     * Send the notification using the alarm id to easily identify the
     * correct notification.
     */
    NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nm.cancel(RetroTimer.NOTIF_SET_ID);
    nm.notify(RetroTimer.NOTIF_TRIGGERED_ID, mBuilder.build());

    /*
     * launch UI, explicitly stating that this is not due to user action so
     * that the current app's notification management is not disturbed
     */
    Intent timerAlert = new Intent(this, TimerAlert.class);
    timerAlert.putExtra(RetroTimer.ALARM_TIME_EXTRA, mAlarmTime);
    timerAlert.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION);
    startActivity(timerAlert);

    play(ring, vibrate);
    startTimeoutCountdown(timeoutMillis);

    // Record the initial call state here so that the new alarm has the
    // newest state.
    mInitialCallState = mTelephonyManager.getCallState();

    // Update the shared state
    RetroTimer.clearAlarm(this);

    return START_STICKY;
}

From source file:com.customprogrammingsolutions.MediaStreamer.MainActivity.java

@Override
public void onResume() {
    super.onResume();

    sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));

    setMediaStateRepresentation();/*from  w  ww .j  a va 2  s .  co m*/

    if (MediaStreamerService.isStreamError()) {
        errorText.setVisibility(View.VISIBLE);
    } else {
        errorText.setVisibility(View.INVISIBLE);
    }
}