Android Foreground Service - Notification that doesn't show Samsung Galaxy device lights -
i have written small application that's intended run service. few times os has decided shutdown service when freeing memory, behavior i'm aware cannot stop. documentation states avoid happening can use foreground service invoking startforeground , passing notification method.
i have written code show notification, , appears working okay. there 1 particular behavior i'm not keen on however, when press 'power' button on device screen switched off 2 'notification' lights @ bottom of samsung galaxy s 1 light up. indicates there's 'new' take @ on phone - such sms or missed phone call. don't think makes sense these light when notification available on there's on-going service.
i understand cannot have foreground service without notification.
i understand cannot cancel foreground service without not being foreground service more.
however, there way stop lights @ bottom of galaxsy s1 lighting though there's new important information available?
edit: here's code i'm using:
intent intentforeground = new intent(this, mainservice.class) .setflags(intent.flag_activity_clear_top | intent.flag_activity_single_top); pendingintent pendintent = pendingintent.getactivity(getapplicationcontext(), 0, intentforeground, 0); notification notification; notificationcompat.builder builder = new notificationcompat.builder(getapplicationcontext()) .setsmallicon(r.drawable.ic_notification) .setticker("service started...") .setcontenttitle("vantage phone client") .setcontenttext("service running") .setcontentintent(pendintent) .setdefaults(notification.default_all) .setautocancel(true) .setonlyalertonce(true) .setongoing(true); notification = builder.build(); notification.flags |= notification.flag_foreground_service; startforeground(1, notification);
you using default_all
defaults, give default lights, , apparently on device, default lights including lighting them up. remove setdefaults()
or limit ones other lights (notification.default_sound
| notification.default_vibrate
).
Comments
Post a Comment