Example usage for org.apache.cordova CordovaArgs optDouble

List of usage examples for org.apache.cordova CordovaArgs optDouble

Introduction

In this page you can find the example usage for org.apache.cordova CordovaArgs optDouble.

Prototype

public double optDouble(int index) 

Source Link

Usage

From source file:com.google.cordova.ChromeAlarms.java

License:Open Source License

private void create(final CordovaArgs args, final CallbackContext callbackContext) {
    try {//w  w w  .  ja v  a2  s  . c o m
        String name = args.getString(0);
        Alarm alarm = new Alarm(name, (long) args.getDouble(1), (long) (args.optDouble(2) * 60000));
        PendingIntent alarmPendingIntent = makePendingIntentForAlarm(name, PendingIntent.FLAG_CANCEL_CURRENT);
        alarmManager.cancel(alarmPendingIntent);
        if (alarm.periodInMillis == 0) {
            alarmManager.set(AlarmManager.RTC_WAKEUP, alarm.scheduledTime, alarmPendingIntent);
        } else {
            alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, alarm.scheduledTime, alarm.periodInMillis,
                    alarmPendingIntent);
        }
        callbackContext.success();
    } catch (Exception e) {
        Log.e(LOG_TAG, "Could not create alarm", e);
        callbackContext.error("Could not create alarm");
    }
}