Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Android Alarm Manager -- Where Did My Alarms Go?

$
0
0

I am using Ben Behrenburg's alarm module for Android, and I am noticing some funky behavior. My code to set the alarm is:

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;
This code is working as I would expect, and the alarm fires if the device does not go to sleep. What's tryly curious is that if I run adb shell dumpsys alarm after the device wakes up, all of the pending intents that were created by the module have been removed. What would cause this issue? The pending intents exist before the device sleeps (checked via adb), but then after the device wakes, those intents are gone. Am I missing some critical bit of code that will cause those intents to persist across a device sleep?

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>