Example usage for android.content Intent ACTION_REBOOT

List of usage examples for android.content Intent ACTION_REBOOT

Introduction

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

Prototype

String ACTION_REBOOT

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

Click Source Link

Document

Broadcast Action: Have the device reboot.

Usage

From source file:Main.java

public static void reboot(Context context) {

    Intent intent = new Intent(Intent.ACTION_REBOOT);
    intent.putExtra("nowait", 1);
    intent.putExtra("interval", 1);
    intent.putExtra("window", 0);
    context.sendBroadcast(intent);/*  w w  w  .  j  av  a2 s .  co m*/

}

From source file:org.dmfs.tasks.notification.NotificationUpdaterService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    String intentAction = intent.getAction();
    if (intentAction != null) {
        switch (intentAction) {
        case ACTION_PIN_TASK:
            // nothing special to do right now
            break;

        case ACTION_PINNED_TASK_START:
            updateNotifications(true, true, true);
            delayedCancelHeadsUpNotification();
            break;

        case ACTION_PINNED_TASK_DUE:
            updateNotifications(true, true, true);
            delayedCancelHeadsUpNotification();
            break;

        case ACTION_COMPLETE:
            if (intent.hasExtra(NotificationActionUtils.EXTRA_NOTIFICATION_ACTION)) {
                resolveUndoAction(intent);
                break;
            }// w ww .j  a v a2 s.c om
            resolveCompleteAction(intent);
            break;

        case ACTION_UNPIN:
            resolveUnpinAction(intent);
            break;

        case ACTION_DELAY_1D:
        case ACTION_DELAY_1H:
            resolveDelayAction(intent);
            break;

        case NotificationActionUtils.ACTION_UNDO:
        case NotificationActionUtils.ACTION_DESTRUCT:
        case NotificationActionUtils.ACTION_UNDO_TIMEOUT:
            resolveUndoAction(intent);
            break;

        case Intent.ACTION_BOOT_COMPLETED:
        case Intent.ACTION_REBOOT:
        case TaskNotificationHandler.ACTION_FASTBOOT:
            updateNotifications(true, false, false);
            break;

        case Intent.ACTION_DATE_CHANGED:
        case Intent.ACTION_TIME_CHANGED:
        case Intent.ACTION_TIMEZONE_CHANGED:
        case ACTION_NEXT_DAY:
            updateNextDayAlarm();
            updateNotifications(false, false, false);
            break;

        case ACTION_CANCEL_HEADUP_NOTIFICATION:
            updateNotifications(false, false, false);
            break;

        default:
            updateNotifications(false, false, false);
            break;
        }
    }

    // check if the service needs to kept alive
    if (mTasksToPin == null || mTasksToPin.isEmpty()) {
        this.stopSelf();
    }
    return Service.START_NOT_STICKY;

}

From source file:nu.yona.app.ui.YonaActivity.java

private void showDeviceRestartNotification(final String message) {
    Intent intent = new Intent(Intent.ACTION_REBOOT);
    PendingIntent pIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0);

    Notification notification = new Notification.Builder(this).setContentTitle(getString(R.string.appname))
            .setContentText(message).setTicker(getString(R.string.appname)).setWhen(0)
            .setVibrate(new long[] { 1, 1, 1 }).setDefaults(Notification.DEFAULT_SOUND)
            .setStyle(new Notification.BigTextStyle().bigText(message)).setSmallIcon(R.mipmap.ic_launcher)
            .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
            .setContentIntent(pIntent).setAutoCancel(false).build();

    notification.flags |= Notification.FLAG_NO_CLEAR;

    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(0, notification);
}