android


Android: OTG Storage notification conflicts with radio c


I am working on an ongoing service which listens for a USB interface connection to a radio. When such a connection is found, this service updates its notification to reflect said connectivity; when a connection is lost (such as through an unplug event, or the radio being turned off), this service will update its notification to reflect said dis-connectivity. This service also writes to a database when it detects a change, so other applications can utilize that information.
This service works properly on USB ports which aren't configured for OTG storage. However, when a USB port with OTG storage enabled is used, I run into some issues where the service notification doesn't update properly, even though the database is being correctly written to. I believe this is because the radio I am connecting to also functions as a OTG storage device, and so once a connection with said radio is made, the OTG storage notification occurs, and I may be losing my notification context. Further, if disconnect from the radio before the OTG storage is able to properly mount, the service notification and database correctly update.
For example, if I am currently connected to a radio and OTG storage has mounted, if I disconnect said radio, the OTG storage will unmount but my service notification will not reflect that change, even though I can see that in the database the change occured properly.
I am running this on Android 4.0.4, and so I thought this issue was merely because my code was 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 I still have issues when updating to 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 a little confused about what the issue might be.
Please let me know if you have any ideas or suggestions, or if there's any code I should have included to be more helpful.
Update: Rather than being an issue with the actual notification, the issue turned out to be a race condition between the OTG storage and my service listening for the same unplug event. In order to workaround this issue, I made my service listen for the change in the OTG storage state. This seems to have resolved the issue, although is admittedly more of a workaround than anything.

Related Links

Andorid sqllite select sub query with count
sudo cordova build android error
How to implement twitter digits api on Android
Why Android use separate xmlns for ContraintLayout
Animating 2 views together hides one where the other view was
Is Eclipse ADT officially abandoned?
Build and compile external library in Android
Non-scrollable RecyclerView with scrollable parent
android TimerTask pausing and starting again
Same activity only once in stack
How to set wallpapers use app-services Wallpaper and Contact photo?
Is it possible to override android string resource from external aar library?
How to determine whether user has accepted or denied a permission in Android?
how to publish a library in jcenter() or mavenCentral()
Edittext cannot Hide Keyboard On Load In android
How to Unblock UI Thread manually

Categories

HOME
android
shell
eclipse
prism
angular2-material
numbers
shiro
error-handling
telegram-bot
code-coverage
trac
okhttp
speech-synthesis
pybossa
code-generation
zerobrane
flatpak
internationalization
firefox-addon
forgot-password
google-data-studio
asp.net-core-webapi
poedit
dataflow-diagram
mongoid6
ckfinder
fat
shared
amazon-quicksight
user-defined-functions
bioinformatics
gitlab-api
quickfixj
installshield-le
xajax
swagger-php
jpad
opensmpp
comparison-operators
laravel-elixir
levenshtein-distance
datacachefactory
movilizer
show-hide
memory-mapping
libgphoto2
magento-2.0.7
mschart
datamaps
posixct
corruption
magic-draw
truezip
boo
sundials
dt
quicktime
xcode-server
x-tag
avspeechsynthesizer
eigenvector
firebase-security
simevents
phpwebsocket
database-relations
pushbots
roadkill-wiki
google-books
poppler
slash
typemock
uncompress
at-job
cosine-similarity
primitive-types
psr-4
jama
ignite-ui
personalization
vsx
maven-scm
accesscontrolexception
nebula
diem
panda3d
cakephp-1.2
correlated-subquery
database-create
promotion-code
tmx
mtu
nhprof
diagrams
delimited-text
maven-1
drupal-fivestar
folding
isapi-extension
data-mapping
business-model
netbeans6.1

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App