BeaconManager#unbind throws IllegalArgumentException
See original GitHub issueSometimes, Beaconmanager#unbind
throws an IllegalArgumentException
:
Caused by: java.lang.IllegalArgumentException: Service not registered: org.altbeacon.beacon.BeaconManager$1@b639ead
1 android.app.LoadedApk.forgetServiceDispatcher LoadedApk.java, line 1029
2 android.app.ContextImpl.unbindService ContextImpl.java, line 1808
3 android.content.ContextWrapper.unbindService ContextWrapper.java, line 551
4 com.example.BeaconUtils$BeaconConsumerImpl.unbindService BeaconUtils.java, line 195
5 org.altbeacon.beacon.BeaconManager.unbind
I’m calling BeaconManager#bind
and BeaconManager#unbind
synchronously in a background thread. I wait for BeaconConsumer#onBeaconServiceConnect
or a timeout, then I wait for MonitorNotifier#didDetermineStateForRegion
or a timeout, I call BeaconManager#unbind
. Occasionally, BeaconManager#unbind
fails. Based on my review of your source. Two things could cause this:
BeaconManager#bind
’s call to BeaconConsumer#bindService
could fail. BeaconManager#bind
doesn’t return this success boolean
to the caller, nor does it handle this failure in any way internally. If we later call BeaconManager#unbind
, the call will throw the IllegalArgumentException
described above.
BeaconManager#beaconServiceConnection
could receive an #onServiceDisconnected
callback after BeaconManager#bind
is called. Since BeaconManager#beaconServiceConnection
is already unbound, when we later call BeaconManager#unbind
, the call will throw the IllegalArgumentException
described above.
Please make BeaconManager#bind
return a success boolean
, and add a onBeaconServiceDisconnect
method to BeaconConsumer
.
Thanks!
Issue Analytics
- State:
- Created 9 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
just want to say Hi because I get an error to a different platform, although it is somewhat related. I’m using Flutter project, I created an issue to the guy created the package using altbeacons. then i get this error.
Edit: kinda fixed the issue now by commenting
beaconClient.unbind()
.closed per #1046