BenCoding AlarmManager通知服务,每年重复一次火灾

时间:2017-07-25 06:59:51

标签: android service notifications alarmmanager appcelerator

  • Titanium SDK 5.5.1
  • bencoding.alarmmanager 0.13

我尝试设置年度生日通知。我使用BenCoding的AlarmService添加属性 repeat =' annual' ,但如果我通过更改设备的日期来尝试此操作,每次切换到另一个时都会显示通知一天。

我为明天的日期设置了以下对象:

{"service":"*MyService*","requestCode":42,"repeat":"yearly","year":2017,"month":6,"day":26,"hour":6,"minute":0,"second":0}

我的服务:

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

setNotification();

Ti.Android.stopService(serviceIntent);

function setNotification(alarm) {
var activity = Ti.Android.currentActivity;
var intent = Ti.Android.createIntent({
    action : Ti.Android.ACTION_MAIN,
    className : 'myActivity',
    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 message = "Time is up!";

var notificationOptions = {
    contentIntent : pending,
    contentTitle : 'Titel',
    contentText : 'Alles Gute zum Geburtstag!',
    tickerText : 'Herzliche Glückwünsche',
    icon : Titanium.App.Android.R.drawable.ic_stat_cake,
    flags : Titanium.Android.FLAG_AUTO_CANCEL | 
Titanium.Android.FLAG_SHOW_LIGHTS | Titanium.Android.FLAG_INSISTENT,
};

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

现在我更改了我的设置并将日期调整到第二天,显示通知。当我将日期更改为3天后,它仍然会出现。等等...通知出现在我将来选择的每个日期。

我收到以下错误...不知道这对这个问题是否重要:

28 08:29:44.998 26897 26910 E linker  : readlink('/proc/self/fd/19') failed: Permission denied [fd=19]
07-28 08:29:44.998 26897 26910 E linker  : warning: unable to get realpath for the library "/data/app/myAppID-1/lib/arm/libbencoding.alarmmanager.so". Will use given name.
07-28 08:29:45.003 26897 26910 E linker  : readlink('/proc/self/fd/19') failed: Permission denied [fd=19]
07-28 08:29:45.003 26897 26910 E linker  : warning: unable to get realpath     for the library "/data/app/myAppID-1/lib/arm/libfacebook.so". Will use given     name.
07-28 08:29:45.011 26897 26897 W TiJSIntervalService: (main) [60,516] The         intent is missing the extra value 'interval', therefore the code will be     executed only once.
07-28 08:29:45.045 26897 26897 W TiJSIntervalService: (main) [33,549] Thrown     while clearing interval service runners: Attempt to invoke interface method     'void java.util.List.clear()' on a null object reference
07-28 08:29:45.045 26897 26897 W TiJSIntervalService:     java.lang.NullPointerException: Attempt to invoke interface method 'void     java.util.List.clear()' on a null object reference
07-28 08:29:45.045 26897 26897 W TiJSIntervalService:   at     ti.modules.titanium.android.TiJSIntervalService.destroyRunners(TiJSIntervalService.java:114)
07-28 08:29:45.045 26897 26897 W TiJSIntervalService:   at ti.modules.titanium.android.TiJSIntervalService.onDestroy(TiJSIntervalService.java:125)
07-28 08:29:45.045 26897 26897 W TiJSIntervalService:   at android.app.ActivityThread.handleStopService(ActivityThread.java:3058)
07-28 08:29:45.045 26897 26897 W TiJSIntervalService:   at android.app.ActivityThread.-wrap21(ActivityThread.java)
07-28 08:29:45.045 26897 26897 W TiJSIntervalService:   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1457)
07-28 08:29:45.045 26897 26897 W TiJSIntervalService:   at android.os.Handler.dispatchMessage(Handler.java:102)
07-28 08:29:45.045 26897 26897 W TiJSIntervalService:   at android.os.Looper.loop(Looper.java:148)
07-28 08:29:45.045 26897 26897 W TiJSIntervalService:   at android.app.ActivityThread.main(ActivityThread.java:5443)
07-28 08:29:45.045 26897 26897 W TiJSIntervalService:   at java.lang.reflect.Method.invoke(Native Method)
07-28 08:29:45.045 26897 26897 W TiJSIntervalService:   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
07-28 08:29:45.045 26897 26897 W TiJSIntervalService:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

0 个答案:

没有答案