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

Launch activity with intent and reciever & alarm manager

$
0
0

Hello all .. i am new to titanium and developing alarm app . My idea is to open activity show alarm details when it pushes notification ... i tried this code but i can not reach to any thing except notification . Thanks in advance

$.win.open();
 
// 1 -  Create the intent
 
var intent = Ti.Android.createBroadcastIntent({
    action: 'com.app.ALARM.ALERT',
    className : 'com.app.ALARM.Notification.js',
    packageName : 'com.app.ALARM'
});
 
// 2 - Create reciever
var broadcastReceiver = Ti.Android.createBroadcastReceiver({
    onReceived : function(e) {
 
        Alloy.createController('Notification').getView.open();
    }
});
Ti.Android.registerBroadcastReceiver(broadcastReceiver, ['com.app.ALARM.ALERT']);
 
function alarm () {
// 3 _ Create the alarm manager
 
var requestCode = 41;
var alarmModule = require('bencoding.alarmmanager');
var alarmManager = alarmModule.createAlarmManager();
var now = new Date();
alarmManager.addAlarmNotification({ 
 
    requestCode:requestCode,    
    year: now.getFullYear(),
    month: now.getMonth(),
    day: now.getDate(),
    hour: now.getHours(),
    minute: now.getMinutes() + 1, 
    contentTitle:'Alarm #3', 
    contentText:'Alarm & Notify Scheduled', 
    sound: Ti.Filesystem.getResRawDirectory() + 'alarm', 
    repeat:60000 
}); 
 
Ti.Android.currentActivity.sendBroadcast(intent);
}

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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