Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for runtime exception on Android #101

Open
anthonyhunter opened this issue Aug 23, 2021 · 2 comments
Open

fix for runtime exception on Android #101

anthonyhunter opened this issue Aug 23, 2021 · 2 comments

Comments

@anthonyhunter
Copy link
Contributor

great plugin, thanks

getting runtime exception on Android Methods marked with @UiThread must be executed on the main thread

see Jumping to the UI thread in Android

changes to FlutterBeaconScanner.java to fix

import android.os.Looper;
import android.os.Handler;

private Handler handler;

class FlutterBeaconScanner {

  public FlutterBeaconScanner(...) {
    ...
    handler = new Handler(Looper.getMainLooper());
  }

  private final RangeNotifier rangeNotifier = new RangeNotifier() {
    @Override
    public void didRangeBeaconsInRegion(Collection<Beacon> collection, Region region) {
      if (eventSinkRanging != null) {
        final Map<String, Object> map = ...
        ...
        handler.post(new Runnable(){
          @Override
          public void run() {
            eventSinkRanging.success(map);
          }
        });
      }
    }
  };

  public void didEnterRegion(Region region) {...}
  public void didExitRegion(Region region) {...}
  public void didDetermineStateForRegion(int state, Region region) {...}

}
@supermuesli
Copy link

can you fork and add a pr with your changes?

alann-maulana pushed a commit that referenced this issue Oct 26, 2021
* updates #101

* improve null check for event sink and fix typo
@eleumasc
Copy link

eleumasc commented Aug 1, 2022

Hi, is it possible to release a version that fixes this bug on pub.dev? Thank you in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants