ReactiveWiFi icon indicating copy to clipboard operation
ReactiveWiFi copied to clipboard

BroadcastReceiver.onReceive always run in the UI thread

Open wangsuicheng opened this issue 5 years ago • 1 comments

return new BroadcastReceiver() {
      @Override public void onReceive(Context context, Intent intent) {
        wifiManager.startScan();
        emitter.onNext(wifiManager.getScanResults());
      }
    };

BroadcastReceiver.onReceive always run in the UI thread, so getScanResults() and startScan still block ui thread

https://stackoverflow.com/questions/5674518/does-broadcastreceiver-onreceive-always-run-in-the-ui-thread

wangsuicheng avatar Jul 07 '20 09:07 wangsuicheng

When we define subscription on the correct scheduler, then it should be executed in the background, but I'm not sure about that. According to this stackoverflow thread, just notification comes in the UI thread, what will be desired in the many cases. Nevertheless getting single notification should slow the app down significantly. I'll have a look at this.

pwittchen avatar Jul 07 '20 19:07 pwittchen