benbahrenburg / benCoding.AlarmManager

Titanium Module for working with the Android AlarmManager
Other
98 stars 84 forks source link

Alarms Removed After Device Sleeps Via Power Button #47

Closed bjanaszek closed 10 years ago

bjanaszek commented 10 years ago

I am creating a series of alarms via the following function:

var alarmMgr = null
            , alarmModule = null
            , delta = -1
            , now = new Date().getTime();

        alarmModule = require( "bencoding.alarmmanager" );
        alarmModule.enableLogging();
        alarmMgr = alarmModule.createAlarmManager();
                alarmMgr.setRootActivityClassName( "com.mycompany.myapp" );

        delta = Math.ceil( ( ( task.DueDate - now ) / 1000 ) / 60 );

        var props = {
            requestCode: task.TaskID
            , minute: delta
            , contentTitle: task.AlarmText
            , contentText: task.AlarmText
            , playSound: false
            , vibrate: true
            , showLights: true
        };

        if( task.repeat !== "undefined" && task.repeat !== null )
        {
            props.repeat = task.repeat;
        }

    alarmMgr.addAlarmNotification( props );

        alarmMgr = null;
        alarmModule = null;

The task object is passed in.

If the device is awake, the alarms fire as expected. I can check the status of the alarms by running the following command:

adb shell dumpsys alarm

If I put the device to sleep via the power button, hit the power button again, and run the above command, all of my app's alarms are gone. Is this a bug or feature? I am using the current release version of the module, so the alarms are being created as type RTC_WAKEUP.