Example usage for android.app AlarmManager setTime

List of usage examples for android.app AlarmManager setTime

Introduction

In this page you can find the example usage for android.app AlarmManager setTime.

Prototype

public void setTime(long millis) 

Source Link

Document

Set the system wall clock time.

Usage

From source file:com.android.managedprovisioning.DeviceOwnerProvisioningService.java

private void setTimeAndTimezone(String timeZone, long localTime) {
    try {//from www  . java2s. c o m
        final AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
        if (timeZone != null) {
            if (DEBUG)
                ProvisionLogger.logd("Setting time zone to " + timeZone);
            am.setTimeZone(timeZone);
        }
        if (localTime > 0) {
            if (DEBUG)
                ProvisionLogger.logd("Setting time to " + localTime);
            am.setTime(localTime);
        }
    } catch (Exception e) {
        ProvisionLogger.loge("Alarm manager failed to set the system time/timezone.");
        // Do not stop provisioning process, but ignore this error.
    }
}