Example usage for android.content Intent ACTION_LOCKED_BOOT_COMPLETED

List of usage examples for android.content Intent ACTION_LOCKED_BOOT_COMPLETED

Introduction

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

Prototype

String ACTION_LOCKED_BOOT_COMPLETED

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

Click Source Link

Document

Broadcast Action: This is broadcast once, after the user has finished booting, but while still in the "locked" state.

Usage

From source file:com.android.talkback.BootReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    TalkBackService service = TalkBackService.getInstance();
    if (service == null) {
        return;/*from   w  w w. j  a v  a  2s .co  m*/
    }

    // We need to ensure that onLockedBootCompleted() and onUnlockedBootCompleted() are called
    // *in that order* to properly set up TalkBack.
    switch (intent.getAction()) {
    case Intent.ACTION_LOCKED_BOOT_COMPLETED:
        // Only N+ devices will get this intent (even if they don't have FBE enabled).
        service.onLockedBootCompleted();
        break;
    case Intent.ACTION_BOOT_COMPLETED:
        if (!BuildCompat.isAtLeastN()) {
            // Pre-N devices will never get LOCKED_BOOT, so we need to do the locked-boot
            // initialization here right before we do the unlocked-boot initialization.
            service.onLockedBootCompleted();
        }
        service.onUnlockedBootCompleted();
        break;
    }
}

From source file:com.example.android.directboot.BootBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    boolean bootCompleted;
    String action = intent.getAction();
    Log.i(TAG, "Received action: " + action + ", user unlocked: " + UserManagerCompat.isUserUnlocked(context));
    if (BuildCompat.isAtLeastN()) {
        bootCompleted = Intent.ACTION_LOCKED_BOOT_COMPLETED.equals(action);
    } else {/*  w w w .j  a  v  a  2  s . c  o m*/
        bootCompleted = Intent.ACTION_BOOT_COMPLETED.equals(action);
    }
    if (!bootCompleted) {
        return;
    }
    AlarmUtil util = new AlarmUtil(context);
    AlarmStorage alarmStorage = new AlarmStorage(context);
    for (Alarm alarm : alarmStorage.getAlarms()) {
        util.scheduleAlarm(alarm);
    }
}