Android: OTG Storage notification conflicts with radio c -


i working on ongoing service listens usb interface connection radio. when such connection found, service updates notification reflect said connectivity; when connection lost (such through unplug event, or radio being turned off), service update notification reflect said dis-connectivity. service writes database when detects change, other applications can utilize information.

this service works on usb ports aren't configured otg storage. however, when usb port otg storage enabled used, run issues service notification doesn't update properly, though database being correctly written to. believe because radio connecting functions otg storage device, , once connection said radio made, otg storage notification occurs, , may losing notification context. further, if disconnect radio before otg storage able mount, service notification , database correctly update.

for example, if connected radio , otg storage has mounted, if disconnect said radio, otg storage unmount service notification not reflect change, though can see in database change occured properly.

i running on android 4.0.4, , thought issue merely because code deprecated:

import android.app.notification; import android.app.notification.builder; import android.app.notificationmanager; import android.app.pendingintent;  notification notification = new notification(icon, contenttitle, time); notification.setlatesteventinfo(this, contenttitle, contenttext,             contentintent);  notification.flags = notification.flag_foreground_service             | notification.flag_no_clear | notification.flag_ongoing_event;  notificationmanager.notify(notification_id, notification); 

but still have issues when updating notification.builder:

notification.builder notibuilder =              new notification.builder(this);  notibuilder.setsmallicon(icon); notibuilder.setcontenttitle(contenttitle); notibuilder.setcontenttext(contenttext); notibuilder.setcontentintent(contentintent); notibuilder.setpriority(2);  notificationmanager.notify(notification_id, notibuilder.getnotification()); 

so i'm little confused issue might be.

please let me know if have ideas or suggestions, or if there's code should have included more helpful.

update: rather being issue actual notification, issue turned out race condition between otg storage , service listening same unplug event. in order workaround issue, made service listen change in otg storage state. seems have resolved issue, although admittedly more of workaround anything.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -