Git Product home page Git Product logo

bencoding.alarmmanager's Introduction

> Hi there! I am Ben

I'm passionate about changing the world through technology.

About Me

Github

  • ๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป Iโ€™m looking to collaborate on OSS projects, publications, and video tutorials

  • ๐Ÿ’ฌ Talk to me about JavaScript, Mobile, Machine Learning, and Open Source

Skills

Connect with me



benbahrenburg

GitHub Stats

benbahrenburg

bencoding.alarmmanager's People

Contributors

adampax avatar beaur avatar benbahrenburg avatar bjanaszek avatar fokkezb avatar janisr avatar jpriebe avatar kwcoffman avatar m1ga avatar manumaticx avatar mcvendrell avatar michielvaneerd avatar nsttu avatar yankovalera avatar zomfg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bencoding.alarmmanager's Issues

custom sound not working

I'm having difficulties in dealing with custom sound in alarm notification.

I've tried all of these below but none of them have successfully fired the sound

sound: Ti.Filesystem.getResRawDirectory() + 'myMp3SoundFile'
sound: Ti.Filesystem.getResRawDirectory() + 'myMp3SoundFile.mp3'
sound: 'myMp3SoundFile'

The notification works silently. Tested on android 4.1.2 device.
On emulator, no errors thrown.

I put the mp3 file under [root]/platform/android/res/raw directory

Using playSound: true (default sound) doesn't work either.
The other apps' notifications are whistling fine. But not my app

please help

AlarmManager: Adding Alarm Notification Causes App to Start/Re-start When Put in Background

Sorry for the wordy title....couldn't figure out a way to cut that down.

I am using the AlarmManager to schedule a notification some time in the future, which is handled by a broadcast receiver. The notification itself works as expected, but I am noticing odd behavior: if I put the app into the background with the Home button after the notification has been scheduled, the app is restarted as it goes into the background. This does not occur prior to scheduling the notification. Is this an issue in the module, or simply in my use of the module? I understand that if it's my problem, this isn't a support forum, but I was curious if this could be an issue in the module itself.

I am using version 0.11. My tiapp.xml looks like this:

<android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest>
            <supports-screens android:anyDensity="true"/>
            <application>
                <activity android:alwaysRetainTaskState="true"
                    android:label="MyApp"
                    android:launchMode="singleTop"
                    android:name=".MyAppActivity" android:theme="@style/Theme.Titanium">
                    <intent-filter>
                        <action android:name="android.intent.action.MAIN"/>
                        <category android:name="android.intent.category.LAUNCHER"/>
                    </intent-filter>
                </activity>
                <receiver android:name="bencoding.alarmmanager.AlarmNotificationListener"/>
                <receiver android:name="bencoding.alarmmanager.AlarmServiceListener"/>
            </application>
        </manifest>
        <services>
            <service type="interval" url="service.js"/>
        </services>
        <property name="ti.android.bug2373.finishfalseroot" type="bool">true</property>
        <property name="ti.android.bug2373.disableDetection" type="bool">true</property>
        <property name="ti.android.bug2373.restartDelay" type="int">500</property>
        <property name="ti.android.bug2373.finishDelay" type="int">0</property>
        <property name="ti.android.bug2373.skipAlert" type="bool">true</property>
        <property name="ti.android.bug2373.message">Initializing</property>
        <property name="ti.android.bug2373.title">Restart Required</property>
        <property name="ti.android.bug2373.buttonText">Continue</property>
    </android>

I am setting the notification like so:

    , _scheduleNotificationAndroid: function( task )
    {
        var alarmMgr = null
            , alarmModule = null
            , delta = -1
            , now = new Date().getTime();

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

        delta = Math.ceil( ( ( task.DueDate - now ) / 1000 ) / 60 );
        var props = {
            requestCode: task.TaskID
            , minute: delta
            , contentTitle: task.AlarmText
            , contentText: task.AlarmText
            , playSound: false
            , vibrate: false
            , showLights: false
        };

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


        alarmMgr.addAlarmNotification( props );

        alarmMgr = null;
        alarmModule = null;
}

alarm sound only works first time

Hi,
this is my "payload":

{"requestCode":2864680751,"second":10,"icon":2130837603,"showLights":true,"vibrate":true,"contentTitle":"Labortimer@15:02","contentText":"Timer 8: duration=00:00:10","playSound":true,"sound":"android.resource://de.appwerft.eppendorf/raw/chord"}

The sound is a mp3 sound and is named 'chord.mp3'.
This is message after creating:

I/bencoding.AlarmManager: (KrollRuntimeThread) [5,21458] Alarm Notification Created

After the 10 seconds comes:

 I/bencoding.AlarmManager: (main) [0,31488] [AlarmManager] Using application Start Activity

and

I/bencoding.AlarmManager: (main) [52,31565] You should now see a notification

I see e new notification on tray with modified text. But the sound is only at first time.
Any ideas?
If I swipe out the message in tray then the alarm sound works again. Every alarm has a new requestCode, but the same contentText and contextTitle. Is it a problem??

Rainer

AlarmManager and android tool

Hi Ben,
is there an example on how to use the android tool to run service using your alarmManager after phone reboot?

Scheduling many Notification

I need to schedule many Notification in different period, but it seems just working with one Notification. For instance I have a code from example project and it just runs the last one (number 3 alarm)

for (var j=1; j<4; j++)
{
    alarmManager.addAlarmNotification({     
        year: now.getFullYear(),
        month: now.getMonth(),
        day: now.getDate(),
        hour: now.getHours(),
        minute: now.getMinutes() + j, //Set the number of minutes until the alarm should go off
        contentTitle:'Alarm '+j, //Set the title of the Notification that will appear
        contentText:'Alarm & Notify Scheduled Repeat', //Set the body of the notification that will apear
        repeat:'daily' //You can use the words hourly,daily,weekly,monthly,yearly or you can provide milliseconds.
    }); 
    var ew = Ti.UI.createAlertDialog({
        title:'Info', message:"You should see your alarm notification in about 2 minutes & repeat each day",
        buttonNames:[Ti.Android.currentActivity.getString(Ti.Android.R.string.ok)]
    });
    ew.show();  

}

Any help, thanks!

AlarmService stops firing daily after ~ 24 days

I'm adding an AlarmService that should repeat daily. However after approximatily 24-25days i do not receive any more notifications. This is experienced on multiple different devices.

This is how i'm setting up the notification:

alarmManager.addAlarmService({
    service:'se.test.testapplication.BackgroundServiceService',
    year: firstDate.getFullYear(),
    month: firstDate.getMonth(),
    day: firstDate.getDate(),
    hour: firstDate.getHours(),
    minute: firstDate.getMinutes(),
    repeat: 'daily'
});

This is the background service that is being run:

var service = Ti.Android.currentService;
var serviceIntent = service.getIntent();

setNotification();

Ti.Android.stopService(serviceIntent);

function setNotification(){
    var activity = Ti.Android.currentActivity;
    var intent = Ti.Android.createIntent({
        action: Ti.Android.ACTION_MAIN,
        className: 'se.test.testapplication.TestApplicationActivity',
        flags: Ti.Android.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Ti.Android.FLAG_ACTIVITY_SINGLE_TOP
    });
    intent.addCategory(Titanium.Android.CATEGORY_LAUNCHER);

    var pending = Ti.Android.createPendingIntent({
        activity: activity,
        intent: intent,
        type: Ti.Android.PENDING_INTENT_FOR_ACTIVITY,
        flags: Ti.Android.FLAG_ACTIVITY_NO_HISTORY
    });

    var notificationOptions = {
        contentIntent: pending,
        contentTitle: 'Notification!',
        contentText: 'Klicka fรถr att รถppna appen',
        when: new Date().getTime(),
        icon: '/images/notification-icon.png',
        flags: Titanium.Android.FLAG_AUTO_CANCEL | Titanium.Android.FLAG_SHOW_LIGHTS,
        sound: Ti.Filesystem.getResRawDirectory() + 'alarm'
    };

    var notification = Ti.Android.createNotification(notificationOptions);
    Ti.Android.NotificationManager.notify(1, notification);

    Ti.Media.vibrate([0,100,100,200,100,100,200,100,100,200]);
}

Everything works as it is supposed to for the first 24 days.

Keep service running after closing from app switcher

Hi,
I've added a alarm service like this:

alarmManager.addAlarmService({
requestCode : 10, service : 'com.dev.app.ServiceService', minute : now.getMinutes(), second : 30, interval : 1000 * 60 * 5
});

Which is working when the app is running or when I close the app with the back button. But as soon as I remove it from the app switcher it stops working. Inside "Settings - Apps - Running" I see "process 0 / service 1" but it won't run. Is there a way to keep it running even if I close it from the switcher?

icon property works only partly

I call:

var notification = {
    requestCode : id + alarm.eta,
    second : alarm.duration,
    icon : Ti.App.Android.R.drawable.alarm_icon,
    contentTitle : 'Labortimer@' + Moment().format('HH:mm'),
    contentText : alarm.label + ': duration=' + formatTime(alarm.duration),
    playSound : true,
    sound : Ti.Filesystem.getResRawDirectory() + sound.toLowerCase()
};
Notify.addAlarmNotification(notification);

On console I see:

{
"requestCode":2861402682,
"second":16,
"icon":2130837603,
"contentTitle":"Labortimer@10:13",
"contentText":"Timer 3: duration=00:00:16",
"playSound":true,
"sound":"android.resource://de.appwerft.eppendorf/raw/note"
}

Issue: I don't see myalarmicon, but a system icon.

NEXUS5 (5.1) Systemicon
NEXUS7 (4.*) it works.
SmartWatch LG it works

Any ideas? I have copied in every drawable folder a PNG. I have also tried to copy PNG in Ressources/android/images/.. folder: same issue.

require() inside an included file from service started by alarmmanager throws error

Thanks for providing a nice wrapper around android's alarmmanager (appreciated by titanium itself - https://jira.appcelerator.org/browse/TIMOB-2752). We're facing one issue though. I'm not sure whether the bug is in alarmmanager or titanium. Please guide us. Using titanium 3.2.2.GA SDK and latest alarmmanager on Nexus S emulator on Windows 7, for the code given below, we get this error consistently:

[ERROR] : V8Exception: Exception occurred at ti:/titanium.js:140: Uncaught TypeError: undefined is not a function
[INFO] : TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
[INFO] : TiApplication: (main) [52,52] Analytics have been disabled
[INFO] : include.js...
[ERROR] : TiExceptionHandler: (main) [115,1154] ----- Titanium Javascript Runtime Error -----
[ERROR] : TiExceptionHandler: (main) [1,1155] - In ti:/titanium.js:140,10
[ERROR] : TiExceptionHandler: (main) [4,1159] - Message: Uncaught TypeError: undefined is not a function
[ERROR] : TiExceptionHandler: (main) [2,1161] - Source: return contextRequire(path, context, sourceUrl);
[ERROR] : V8Exception: Exception occurred at ti:/titanium.js:140: Uncaught TypeError: undefined is not a function

Can be reproduced using following code:

tiapp.xml (same as given in example except the service is of standard type):

        <service type="standard" url="testservice.js"/>

app.js:

var alarmModule = require("bencoding.alarmmanager");
var alarmManager = alarmModule.createAlarmManager();
var win = Titanium.UI.createWindow({
title:"Tab 1", backgroundColor:"#fff", title:"Alarm Manager Tests",
exitOnClose: true,
layout: "vertical"
});

var btn6 = Ti.UI.createButton({
title:"Schedule service", width: 150, height:75
});
win.add(btn6);
btn6.addEventListener("click",function(e){
alarmManager.addAlarmService({
service:"com.appworkbench.alarmtest.TestserviceService",
minute:1,
repeat:60000,
forceRestart: true
});
var ew = Ti.UI.createAlertDialog({
title:"Info", message:"The Service provided will be started in about 1 minute & repeat each minute. Press back button to exit app and watch console...",
buttonNames:[Ti.Android.currentActivity.getString(Ti.Android.R.string.ok)]
});
ew.show();
});

var btn10 = Ti.UI.createButton({
title:"Cancel service", width: 150, height:75
});
win.add(btn10);
btn10.addEventListener("click",function(e){
alarmManager.cancelAlarmService();
var ew = Ti.UI.createAlertDialog({
title:"Info", message:"Your alarm service has been cancelled",
buttonNames:[Ti.Android.currentActivity.getString(Ti.Android.R.string.ok)]
});
ew.show();
});
win.open();

// Include a file that has require() statement.
// Will work fine on first app launch. But if
// app is exited immediately after starting
// service, then after a service run, if app
// is opened again, this will throw an error
Ti.include("include.js");

include.js:

Ti.API.info("include.js...");

// require() inside an included file throws error
// in certain scenario
var log = require("log");
log.info("Log test...");

log.js:

exports.info = function(msg) {
Ti.API.info(msg);
};

testservice.js:

Ti.API.info("Service started...");

// Include a file that has require() statement.
// If app is exited immediately after starting
// service, then first time service run will
// throw an error
Ti.include("include.js");

1

Unable to run testservice.js in any case !!

Hey,

I have just Imported the same code as you have written and created a demo app for me. But when I click on any of alarm and service it just shows a alert which says :

The Service provided will be started in about 2 minutes

But after two minutes there is nothing happening. No alert or logger output as written in testservice.js which is located in Resources/android directory !!

Ti.API.info('Test Service!!!!!!');
alert('Hello from the test service');

Here is my tiapp.xml registering for services

<property name="ti.ui.defaultunit" type="string">system</property>
    <property name="ti.android.threadstacksize" type="int">32768</property>
    <property name="ti.android.compilejs" type="bool">false</property>
    <property name="ti.android.debug" type="bool">true</property>
    <property name="ti.android.fastdev" type="bool">false</property>
    <property name="ti.ui.defaultunit">system</property>
    <android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest>
            <supports-screens android:anyDensity="false"/>
            <application>
                <activity android:alwaysRetainTaskState="true"
                    android:configChanges="keyboardHidden|orientation"
                    android:label="AlarmTest"
                    android:launchMode="singleTop"
                    android:name=".AlarmtestActivity" android:theme="@style/Theme.Titanium">
                    <intent-filter>
                        <action android:name="android.intent.action.MAIN"/>
                        <category android:name="android.intent.category.LAUNCHER"/>
                    </intent-filter>
                </activity>
                <receiver android:name="bencoding.alarmmanager.AlarmNotificationListener"/>
                <receiver android:name="bencoding.alarmmanager.AlarmServiceListener"/>
            </application>
        </manifest>
        <services>
            <service type="interval" url="tesstservice.js"/>
        </services>
    </android>
    <modules>
        <module platform="android" version="0.5">bencoding.alarmmanager</module>
    </modules>

I am not able to figure out why is this happening.

Custom sound doesn't work

I know this should be fixed in 0.9, but I still hear the default sound. I have:

  • { sound: Ti.Filesystem.getResRawDirectory() + 'notification' }
  • An simpel MP3 at platform/android/res/raw/notification.mp3
  • The MP3 (symlink) at build/android/res/raw/notification.mp3 after build

When I enable debug logging the modules shows it has sound enabled, but not for what sound so this makes it harder to debug:

02-24 12:09:57.012: D/bencoding.AlarmManager(9169): (main) [59906,135492] In Alarm Notification Listener
02-24 12:09:57.012: D/bencoding.AlarmManager(9169): (main) [1,135493] requestCode is 2
02-24 12:09:57.012: D/bencoding.AlarmManager(9169): (main) [0,135493] contentTitle is Dagboek
02-24 12:09:57.012: D/bencoding.AlarmManager(9169): (main) [0,135493] contentText is Lees nu Dag 4: Jij bent die schat, die parel!
02-24 12:09:57.012: D/bencoding.AlarmManager(9169): (main) [0,135493] className is 
02-24 12:09:57.012: D/bencoding.AlarmManager(9169): (main) [0,135493] User provided an icon of 2130837504
02-24 12:09:57.012: D/bencoding.AlarmManager(9169): (main) [0,135493] On notification play sound? true
02-24 12:09:57.012: D/bencoding.AlarmManager(9169): (main) [0,135493] On notification vibrate? true
02-24 12:09:57.012: D/bencoding.AlarmManager(9169): (main) [0,135493] On notification show lights? true
02-24 12:09:57.012: D/bencoding.AlarmManager(9169): (main) [0,135493] NotificationManager created
02-24 12:09:57.012: D/bencoding.AlarmManager(9169): (main) [1,135494] Using application Start Activity
02-24 12:09:57.012: D/bencoding.AlarmManager(9169): (main) [2,135496] setting notification flags
02-24 12:09:57.012: D/bencoding.AlarmManager(9169): (main) [0,135496] setLatestEventInfo
02-24 12:09:57.012: D/bencoding.AlarmManager(9169): (main) [0,135496] Notifying using requestCode =2

Process for background service

Hi Ben,
I'm using this module to register a background service to check new feeds on my server.
I works fine until I swipe app (clear recent app). After doing that, I've check on running app (in setting) I see that "0 processes and 1 service" -- "restarting" and my service does not keep running.
So how can I provide process for the service if I clear recent app.

Sony LT29i
Android 4.3

Running from an activitiless service

Does this module require an activity? It works like a charm from my service while the app is running. If I close the app and my service gets restarted it can no longer initialize the alarm manager. In one case any scheduled notification never appears if the service is currently restarting. In case two, if I schedule a notification service for a certain time it won't run either. It seems like this module won't properly run solely in the background from a service.

Alarms Firing Instantly, not at scheduled time

Hi,

This is a great module coupled with the iOS version. I'm using both. The iOS version is smooth sails. However with the Android version, I cant get scheduled notification to work. The alarm always fires instantly after I set the alarm.

My codes are below:

var Globals = require('/models/Globals');
var DB = require("/models/DB");
var osname = Ti.Platform.osname;
var notify = osname == 'iphone' ? require('bencoding.localnotify') : null;
if(osname == 'android') {
    var alarmModule = require('bencoding.alarmmanager');
    var alarmManager = alarmModule.createAlarmManager();
}

var Reminder = (function() {
    var db = new DB();
    db.install();

    function Reminder() {}

    Reminder.newReminder = function(name, listname, duedate, notes) {
        var duedateUnix = parseInt(duedate.getTime() / 1000);
        db.execute("INSERT INTO reminder (name, listname, starred, duedate, notes) VALUES(?, ?, ?, ?, ?)", [name, listname, 0, duedateUnix, notes]);
        var sql = "SELECT id FROM reminder WHERE name = ? AND listname = ? AND duedate = ? LIMIT 1";
        var result = db.execute(sql, [name, listname, duedateUnix]);
        if(result.isValidRow()) {
            this.createNotification(result.fieldByName('id'), name, duedate);
            return true;
        }
        return false;
    };

    Reminder.getAllReminders = function() {
        var sql = "SELECT * FROM reminder ORDER BY id";
        var result = db.execute(sql);

        var reminders = [];
        while(result.isValidRow()) {
            reminders.push({
                id: result.fieldByName('id'),
                name: result.fieldByName('name'),
                listname: result.fieldByName('listname'),
                starred: result.fieldByName('starred'),
                duedate: result.fieldByName('duedate'),
                notes: result.fieldByName('notes')
            });
        }
        result.close();

        return reminders;
    };

    Reminder.deleteReminder = function(id) {
        var sql = "DELETE FROM reminder WHERE id = ? LIMIT 1";
        db.execute(sql, [id]);

        this.cancelNotification(id);
    };

    Reminder.cancelNotification = function(id) {
        if(osname == 'iphone') {
            notify.cancelLocalNotification(id)
        }
        else if(osname == 'android') {
            alarmManager.cancelAlarmNotification(id); 
        }
    };

    Reminder.createNotification = function(id, msg, when) {
        if(osname == 'iphone') {
            notify.scheduleLocalNotification({
                alertBody: msg,
                alertAction: "View",
                userInfo: {
                    "id": id
                },
                date: when
            });
        }
        else if(osname == 'android') {
            alarmManager.addAlarmNotification({ 
                requestCode: id,    
                year: when.getFullYear(),
                month: when.getMonth(),
                day: parseInt(when.getDate()),
                hour: parseInt(when.getHours()),
                minute: parseInt(when.getMinutes())+1,
                second: when.getSeconds(),
                contentTitle: 'Reminder',
                contentText: msg,
                vibrate: true,
                showLights: true,
                playSound: true
            }); 
        }
    };

    return Reminder;
})();

module.exports = Reminder;

My tiapp.xml is below:

     <android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest android:versionCode="74">
            <uses-feature android:name="android.hardware.touchscreen" android:required="true"/>
            <supports-screens android:anyDensity="true"/>
            <application>
                <activity android:alwaysRetainTaskState="true"
                    android:configChanges="keyboardHidden|orientation" android:launchMode="singleTop"
                    android:name="org.appcelerator.titanium.TiActivity" android:screenOrientation="portrait"/>
                <receiver android:name="bencoding.alarmmanager.AlarmNotificationListener"/>
                <receiver android:name="bencoding.alarmmanager.AlarmServiceListener"/>
            </application>
        </manifest>
    </android>

Would appreciate any help. Thank you in advance.

Best,
Tista

Example app crash (Ti SDK 3.1.0)

Hi,

This module seems to be really useful to me. I hope alarms survice reboots (by registering the BOOT_COMPLETED event), I have to check this. But the app keeps crashing on me. This is what logcat says:

05-30 16:48:32.226: E/TiApplication(5716): (main) [6,220] No valid root or current activity found for application instance
05-30 16:48:32.234: E/TiApplication(5716): (main) [2,222] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start receiver bencoding.alarmmanager.AlarmNotificationListener: java.lang.NullPointerException; Titanium 3.1.0,2013/04/15 18:46,57634ef
05-30 16:48:32.234: E/TiApplication(5716): java.lang.RuntimeException: Unable to start receiver bencoding.alarmmanager.AlarmNotificationListener: java.lang.NullPointerException
05-30 16:48:32.234: E/TiApplication(5716):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2383)
05-30 16:48:32.234: E/TiApplication(5716):  at android.app.ActivityThread.access$1500(ActivityThread.java:141)
05-30 16:48:32.234: E/TiApplication(5716):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1310)
05-30 16:48:32.234: E/TiApplication(5716):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-30 16:48:32.234: E/TiApplication(5716):  at android.os.Looper.loop(Looper.java:137)
05-30 16:48:32.234: E/TiApplication(5716):  at android.app.ActivityThread.main(ActivityThread.java:5041)
05-30 16:48:32.234: E/TiApplication(5716):  at java.lang.reflect.Method.invokeNative(Native Method)
05-30 16:48:32.234: E/TiApplication(5716):  at java.lang.reflect.Method.invoke(Method.java:511)
05-30 16:48:32.234: E/TiApplication(5716):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-30 16:48:32.234: E/TiApplication(5716):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-30 16:48:32.234: E/TiApplication(5716):  at dalvik.system.NativeStart.main(Native Method)
05-30 16:48:32.234: E/TiApplication(5716): Caused by: java.lang.NullPointerException
05-30 16:48:32.234: E/TiApplication(5716):  at bencoding.alarmmanager.AlarmNotificationListener.showNotification(AlarmNotificationListener.java:73)
05-30 16:48:32.234: E/TiApplication(5716):  at bencoding.alarmmanager.AlarmNotificationListener.onReceive(AlarmNotificationListener.java:58)
05-30 16:48:32.234: E/TiApplication(5716):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2376)
05-30 16:48:32.234: E/TiApplication(5716):  ... 10 more
05-30 16:48:32.234: D/TiProperties(5716): (KrollRuntimeThread) [6,228] getString called with key:ti.deploytype, def:development

I just start the app and press the upper left button "Alarm & Notify Basic Repeat". Then backed out the app.

Tested on hardware (Samsung Galaxy Nexus), Android OS 4.2.2. Could you fix this? Do you need more/other info?

can i ask a question?

I need to use addAlarmService.
app service is running well.
but i close app with android task, service stop and service will start after 5 ~ 10 seconds.
this is good. i want it.

with below message.

08-04 17:39:46.533: I/TiApplication(27634): (main) [0,0] checkpoint, app created.
08-04 17:39:46.683: I/TiApplication(27634): (main) [143,143] Titanium 3.3.0 (2014/07/11 12:36 787cd39)
08-04 17:39:46.733: I/TiApplication(27634): (main) [56,199] Titanium Javascript runtime: v8

app created. but not create Activity.
so my code not working.

background.js

/*global Ti */
var service = Ti.Android.currentService;
if(!service) {
  Ti.API.info("I'm zombie service.");
} else {
  var intent = service.getIntent();
  Titanium.App.fireEvent('backgroundEvent', {});
}

'backgroundEvent' is not fired!

app.js

Ti.App.addEventListener('backgroundEvent', function(){
    Ti.API.info('backgroundEvent fired!');
});

I think app.js is not excute. when service restart.

i want connect sqlite in backgroundEvent event.

how can i make this?

help plz.

Can this support badges

We are using this within a project, and we'd like to update the badge of the appicon to show the number of notifications received since they last looked at the app.

Does the module support badges?

Events for notifications when app is running

Are there any way to get an event while the app is running when a notification is firing?

Something like:

var AlarmManager = require('bencoding.alarmmanager');
AlarmManager.addEventListener('alarmnotification', function (e) {});

64bit

Module needs to be upgraded to support 64-bit.

Triggering app start with parameter?

Hi Ben,
you module works awesome. My question: In the tray comes my message. Now I'm looking for a way the start the app with a parameter to "link" a special "page". Is it possible?

crash on v8 when AlermTest startup

1.Import AlermTest Example into Titanium studio Workspace.
2.Build and Install into Android device.
3. launch AlermTest apk on Android device.
then Crash with logcat :

09-28 09:57:46.687: E/TiApplication(5628): (KrollRuntimeThread) [37,338] Sending event: exception on thread: KrollRuntimeThread msg:java.lang.UnsatisfiedLinkError: Couldn't load bencoding.alarmmanager: findLibrary returned null; Titanium 2.0.2,2012/05/30 10:21,2ff31a3

It is caused by missing directories and files in AlermTest/modules deirectory for v8 runtime.
The missing directories and files are ;
platform/
libs/armeabi/libbencoding.alarmmanager.so
libs/armeabi-v7a/libbencoding.alarmmanager.so

Force stopping app causes reminders to not work

Hey,

Just wondering if you can help on this, to determine whether this is a bug, or expected behaviour, if i set a reminder and stay within the app, or even background the app, the reminder is shown fine. But if i force stop the app, no reminders are created.

Can you confirm if this is a bug, or expected, and if there is any workaround?

Compiling the module issue

i cant complie the module
steps

  1. i have the downloaded sample and its in my workspace
  2. i have set all the build.properties correctly including NDK
  3. i have ant path

when i compile using ant i can see errors such as lib does not exist
if i manually add the lib folder then i am getting some other issues

how to make this module compile error free plz suggest

i am using 3.0.2 version and i have added those ndk macros in installation DIR.

Do i need to update .classpath ?? i cant see that file i havent made any changes to .classpath file .
plz help how to compile this module

Thanks

Repeat option Issues

Hi,
I recently installed your module (0.7 from github) and am using the Google APIs 4.0 emulator, however I am still receiving the error mentioned in
#2
and the service runs only once. The code and issue are as follows:-

//CODE
var alarmModule = require('bencoding.alarmmanager');
var alarmManager = alarmModule.createAlarmManager();
var now = new Date();
alarmManager.addAlarmService({
service : 'com.acme.jbacsrc.CheckService',
year : now.getFullYear(),
month : now.getMonth(),
day : now.getDate(),
hour : now.getHours(),
minute : now.getMinutes()+1, //Set the number of minutes until the alarm should go off
repeat : 60000
});
//END CODE

On running the following the service successfully executes once and shows message

//INFO
[WARN]TiJSIntervalService( 951) [54973,61769] The intent is missing the extra value 'interval', therefore the code will be executed only once.
//END INFO

I have specified a repeat as shown in the code above. Is there anything I am missing? Do I need to specify a separate repeat and interval option, if so what would be the difference. Please do let me know.
Thanks

Delay when Add new Alarm.

I try to use AlarmManager Module and it work done , but it make delay in time min or 2 min .
alarmManager.addAlarmNotification({
requestCode:requestCode,
icon:Ti.App.Android.R.drawable.appicon ,
year: now.getFullYear(),
month: now.getMonth(),
day: now.getDate(),
hour: now.getHours(),
minute: now.getMinutes() + 2 , //Set the number of minutes until the alarm should go off
playSound:true,
sound:Ti.Filesystem.getResRawDirectory() + 'sound.wav' ,
contentTitle:'Alarm #3', //Set the title of the Notification that will appear
contentText:'Alarm & Notify Scheduled', //Set the body of the notification that will apear
repeat:'daily' //You can use the words hourly,daily,weekly,monthly,yearly or you can provide milliseconds.
//Or as shown above you can provide the millesecond value
});
i donnot know why this delay , any suggestion.

Example creates two icons on dashboard.

Hi Ben,

I'm successfully able to create alarms using your alarmmanager module. But it create two icons on the dashboard one my app and other icon with name "AlarmTest".

How can we hide that icon with name "AlarmTest"?

typo in README.md

cancelAlarmService() is called addAlarmService(), both in title and example ;]

Example included not work

Sorry for my english.

Thanks for that awesome work!! :) But I have problems with it...
When I import the proyect in my titanium and then I run in my Android 2.2 emulator then app crash after splash window. The same respound in my android 4.0 device.

I really need it to work.

Thanks a lot!

You can see the result here: http://imageshack.us/photo/my-images/685/sorrys.jpg/

Cancel notification on building src doesn't work

Hello,
When i build the source in an titanium module project i cant cancel any event.

rules 114 and 115 give an error
int requestCode = args.optInt("requestCode", DEFAULT_REQUEST_CODE);
intent.setData(Uri.parse("alarmId://" + requestCode));
int requestCode is already set well seen that the requestcode is already set above these lines i have deleted it, second Uri is not imported (i assume importing android.net.uri) will resolve this.

Done that then build it, cant cancel a notification. I set a notification with request code 20 and cancel one on 20 it just doesn't work.

Could this be because i build wrong, build settings:

titanium.platform=Library/Application Support/Titanium/mobilesdk/osx/2.1.5.v20130108131707/android
android.platform=Documents/adt-bundle-mac/sdk/platforms/android-8
google.apis=Documents/adt-bundle-mac/sdk/add-ons/addon-google_apis-google-8
android.ndk=Desktop/android-ndk-r8d

Working with mac osx and as you can see build with titanium sdk 2.1.5.v20130108131707

Thanks for any help!

problems in Multiple reminders

in first click the reminder set successfully but when i click on another time to set reminder the dialog box does not disappear.

var alarmModule = require('bencoding.alarmmanager');
var alarmManager = alarmModule.createAlarmManager();
var requestCode=41;
var onWebViewListener = function(e) {
var dtime=e.message;

        var dt1=dtime.split(':');

            var dialog = Titanium.UI.createOptionDialog({
                    options: ['2 Mins Before','10 Mins Before', 'No Reminder'],
                    cancel:3
        }); 
            dialog.show();

        dialog.addEventListener('click', function(e) {

if (e.index==0){

               var  min = parseInt(dt1[1]);
                var hours = parseInt(dt1[0]);

                if(min==0)
                                   {
                            var hours=hours-1;
                            var mins=60;
                                      }
                              var mins=min-2;

                      var date="06/05/2013";
                         var arr=date.split("/");

                     var year=parseInt(arr[2]);
                    var month=parseInt(arr[1]);
                var day=parseInt(arr[0]);
                var dt=new Date(year,month,day,hours,mins,00);

                alarmManager.addAlarmNotification({
                        requestCode:requestCode,
                year:dt.year,
                month:dt.month,
                day:dt.day,
                    hours:dt.hours,
                minute:dt.mins-2,
                contentTitle:'Sap Forum',
                contentText:'Alarm & Notify Scheduled'

                });


            } 
            else if(e.index==1){
                var min = parseInt(dt1[1]);
                var hours = parseInt(dt1[0]);

                if(min==0)
                                   {
                            var hours=hours-1;
                            var mins=60;
                                      }
                              var mins=min-10;

                      var date="08/05/2013";
                         var arr=date.split("/");

                     var year=parseInt(arr[2]);
                    var month=parseInt(arr[1]);
                var day=parseInt(arr[0]);
                var dt=new Date(year,month,day,hours,mins,00);

                alarmManager.addAlarmNotification({
                        requestCode:requestCode,
                year:dt.year,
                month:dt.month,
                day:dt.day,
                    hours:dt.hours,
                minute:dt.mins-10,
                contentTitle:'Sap Forum',
                contentText:'Alarm & Notify Scheduled for'+ dtime

                });
            }


    //setTimeout(function(){dialog.hide({animated:false});},2000);

});
}
self.addEventListener('load', function(e) {
Ti.App.addEventListener('onWebView', onWebViewListener);
});
return self;
}

AlarmManager in Android

Hi All,

I have included Bencoding.AlarmManager module in my Titanium Android project. while compiling the project, i am getting "[ERROR] : TiExceptionHandler: (main) [0,61802] - In ti:/module.js:280,9" error.

[ERROR] : TiExceptionHandler: (main) [1,61803] - Message: Uncaught Error: Requested module not found: bencoding.alarmmanager
[ERROR] : TiExceptionHandler: (main) [0,61803] - Source: throw new Error("Requested module not found: " + request);
[ERROR] : V8Exception: Exception occurred at ti:/module.js:280: Uncaught Error: Requested module not found: bencoding.alarmmanager

please assist me to resolve the issue.

Thanks
Ashish

Example tiapp.xml

The example tiapp.xml dont have the receivers configured (has been removed), but the doc makes a reference to that.

The requestCode is not woking.

Just created alarmNotification for two at same time, and apply different requestCode for each notification. But only the last one occurred. Even alarmService is the same.

PR:: adding of parameter 'itemId' to 'addAlarmService'

Hi Ben,
I have cloned you last version and modified. Now it is possible:

am.addAlarmService({
     service : 'de.appwerft.eppendorf.LabortimerService',
     second : alarm.duration,
     forceRestart : true,
     itemId : '' + alarm.id
 });

and in
service.js:

var intent = Ti.Android.currentService.getIntent();
var itemId = intent.getStringExtra('itemId');

I don't know how I can pull. How can I do?

How to pass and retrieve custom variables in my testservice.js ?

I want to pass two extra variables namely variable_1 and variable_2

btn7.addEventListener('click', function(e) {
    var now = new Date();
    alarmManager.addAlarmService({
        //The full name for the service to be called. Find this in your AndroidManifest.xml Titanium creates
        service : 'com.test.app.TestserviceService',
        year : now.getFullYear(),
        month : now.getMonth(),
        day : now.getDate(),
        hour : now.getHours(),
        minute : now.getMinutes() + 2,
        variable_1 : "My Cutom Varaibale 1 ",  // Passing variable one here
        variable_2 : "My Cutom Varaibale 1 ",  // Passing another variable here

    });
    var ew = Ti.UI.createAlertDialog({
        title : 'Info',
        message : "The Service provided will be started in about 2 minutes",
        buttonNames : [Ti.Android.currentActivity.getString(Ti.Android.R.string.ok)]
    });
    ew.show();
});

How to get these variable in my servicelistener file i.e testservice.js. I want something like

var recieved_variable_1 =  ????
var recieved_variable_2 =  ????

Alarms Removed After Device Sleeps Via Power Button

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.

bencoding.android.tools is not working

Hi Ben,
kindly see my code here. You have closed the previous thread.
My question was your bencoding.android.tools is not working. My app doesn't launch when device boot.

I am testing it on Samsung Galaxy S3 and Android JellyBean 4.2.1. I have pasted my tiapp.xml and app.js code here.

Sound for Notifications

Hi Thanks for this module, it's a great help. One question is am I able to set a sound for the notifications? or by using the defaults: option?

Thanks

Sleep mode : Service Manager work only on the emulator,on device no service starts

Hi Ben!!
Really strange, i've compiled my app with Titanium SDK version: 3.1.3GA on android
4.0 armeabi v-7a,using bencoding.alarmmanager V0.8
On emulator everything is working fine but not on device.
I think that on device don't start the service when the device goes in sleep mode with screen off.
The file manifest.xml and tiapp.xml should be OK!!
What can i check???
I'm a newbie on Titanium,and i've unzipped your module and copied in titanium android module folder.
Thanks in advance

A snippet of my app:
//Import our module into our Titanium App
var requestCode = 41;
var alarmModule = require('bencoding.alarmmanager');
var alarmManager = alarmModule.createAlarmManager();
//contatore dei badge
//var reset_badge = Titanium.App.Properties.setDouble("badge",0);

//Create a date variable to be used later
var now = new Date();
//Schedule a service to be run (once) in about two minutes, then to run at the same time each day
alarmManager.addAlarmService({
//The full name for the service to be called. Find this in your AndroidManifest.xml Titanium creates
service:'com.mgl.localwind.BgService',
//requestCode:41,
forceRestart:true,
year: now.getFullYear(),
month: now.getMonth(),
day: now.getDate(),
hour: now.getHours(),
minute: now.getMinutes() , //Set the number of minutes until the alarm should go off
repeat:360000 //You can use the words hourly,daily,weekly,monthly,yearly or you can provide milliseconds.
});

repeat option breaks addAlarmService

Hi if I add the repeat option, to the addAlarmService function, it never fires? omitting it and it works fine?

This is also the case, when using your example project?

Background issue notification with null activity.

background service and notification work normally if your app user not doing task kill.

How about if use kill the app?

background service will issue notification with null activity where you get it from Ti.Android.currentActivity.

Thats is the issue i found.
Any body solved it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.