c# - Android AlarmManager (sometimes) provides extra notification -
i working on application uses alarmmanager generate notification user @ later date.  alarm arrives (on devices tested) 1 device (samsung galaxy tab3, android 4.4.2) receives 2 notifications (presumably 1 alarmmanager, , 1 broadcast receiver of app).  code both of course same, , haven't seen issue before.
 
the code written in c# xamarin, pretty vanilla. alarmmanager creates broadcast broadcast filter picked elsewhere in app (and works fine):
private pendingintent createintent (models.notifications.localnotificationmodel notification, pendingintentflags flag) { if (notification.isactive) { //create broadcast intent var broadcastintent = new intent (broadcastfilter);
            //add information receiver of should done notification             var id = notification.id;             var message = notification.message;             var badgenumber = notification.badgenumber;             var dateofevent = notification.eventdatetime;             var iconpath = notification.iconpath;             var isactive = notification.isactive;             var isoverride = notification.isoverride;              //needs information create notification             broadcastintent.putextra (id, id);             broadcastintent.putextra (message, message);             broadcastintent.putextra (dateofevent, dateofevent.toshortdatestring () + " " + dateofevent.toshorttimestring ());              //get broadcast pending intent             var source = pendingintent.getbroadcast (_context, (int)id, broadcastintent, flag);              return source;         }         return null;     }      public void add(models.notifications.localnotificationmodel notification)     {         if (!_isinitialized)             throw new applicationexception("localnotificationservice not initialized");          var source = createintent (notification,pendingintentflags.oneshot);          //convert notification milliseconds since epoch         var sinceepoch = notification.eventdatetime.touniversaltime() - new datetime(1970, 1, 1);         var mssinceepoch = (long)sinceepoch.totalmilliseconds;          //assign pending intent alarmmanager         _alarmmanager.set(alarmtype.rtcwakeup, mssinceepoch, source);     }      
it error on part, there proof of concept version of application on tablet, different app used same bundle id, , result received same broadcast.
Comments
Post a Comment