Q: Android how to prevent binding to Remote Messenger Service twice to prevent java.lang.IllegalStateException: This message is already in use While developing react-native geolocation module I run into following problem with binding to Remote Messenger Service.
I'm using LocationService, which is basically same as MessengerService from android service example. LocationService can live in separate process, so communication with it is via Messenger IPC. I'm binding to service in BackgroundGeolocationModule in doBindService method:
void doBindService() {
    // Establish a connection with the service.  We use an explicit
    // class name because there is no reason to be able to let other
    // applications replace our component.
    if (mIsBound) { return; }

    mMessenger = new Messenger(new IncomingHandler());

    final Activity currentActivity = this.getCurrentActivity();
    Intent locationServiceIntent = new Intent(currentActivity, LocationService.class);
    locationServiceIntent.putExtra("config", mConfig);
    currentActivity.bindService(locationServiceIntent, mConnection, Context.BIND_IMPORTANT);
}

Instance member mIsBound should prevent binding  to service twice. And it works pretty well in similar module I'm developing for cordova.
However react-native has feature that enables "live code reload" on changes in javascript part of application. Not sure how this "live reload" is implemented, but it doesn't call onDestroy (where unbind from service is done - code not in repo yet), but member mIsBound is false so it seems module is reinitialized completely while doing reload. 
As result client is registered twice within single service instance, which result in following exception and app crash:
AndroidRuntime  D  Shutting down VM
                E  FATAL EXCEPTION: main
                E  Process: com.marianhello.RNBGExample, PID: 11937
                E  Theme: themes:{default=overlay:com.resurrectionremix.pitchblack, fontPkg:com.resurrectionremix.pitchblack, com.android.systemui=overlay:com.resurrectio
                   nremix.pitchblack, com.android.systemui.navbar=overlay:com.resurrectionremix.pitchblack}
                E  java.lang.IllegalStateException: { when=0 what=4 target=com.marianhello.react.BackgroundGeolocationModule$IncomingHandler } This message is already in 
                   use.
                E      at android.os.MessageQueue.enqueueMessage(MessageQueue.java:538)
                E      at android.os.Handler.enqueueMessage(Handler.java:631)
                E      at android.os.Handler.sendMessageAtTime(Handler.java:600)
                E      at android.os.Handler.sendMessageDelayed(Handler.java:570)
                E      at android.os.Handler.sendMessage(Handler.java:507)
                E      at android.os.Handler$MessengerImpl.send(Handler.java:721)
                E      at android.os.Messenger.send(Messenger.java:57)
                E      at com.marianhello.bgloc.LocationService.sendClientMessage(LocationService.java:369)
                E      at com.marianhello.bgloc.LocationService.handleLocation(LocationService.java:348)
                E      at com.marianhello.bgloc.AbstractLocationProvider.handleLocation(AbstractLocationProvider.java:81)
                E      at com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider.onLocationChanged(DistanceFilterLocationProvider.java:318)
                E      at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:285)
                E      at android.location.LocationManager$ListenerTransport.-wrap0(LocationManager.java)
                E      at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:230)
                E      at android.os.Handler.dispatchMessage(Handler.java:102)
                E      at android.os.Looper.loop(Looper.java:148)
                E      at android.app.ActivityThread.main(ActivityThread.java:5461)
                E      at java.lang.reflect.Method.invoke(Native Method)
                E      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                E      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
 unknown:React  W  Calling JS function after bridge has been destroyed.

My question is there any way how to detect client is already bound to service, so binding can be skipped in that case?
Related react-native issue: https://github.com/facebook/react-native/issues/9773
