You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.
I'm using your library in a react-native project where on user logout we want to stop the ibeaconscanner. We do this by sending a broadcast which we catch in a service called BeaconService:
public class UserStopServiceReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
BeaconService.this.destroyIntentional = true;
IBeaconScanner.getInstance().stop();
BeaconService.this.stopSelf();
}
}
However, not long after logout this crashes the app with the follow error:
09-19 17:38:50.008 19149-19149/be.imec.apt.wappr.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: be.imec.apt.wappr.debug, PID: 19149
java.lang.NullPointerException: Attempt to invoke virtual method 'android.bluetooth.le.BluetoothLeScanner android.bluetooth.BluetoothAdapter.getBluetoothLeScanner()' on a null object reference
at mobi.inthepocket.android.beacons.ibeaconscanner.DefaultBluetoothFactory.canAttachBluetoothAdapter(DefaultBluetoothFactory.java:46)
at mobi.inthepocket.android.beacons.ibeaconscanner.DefaultScanService.timedOut(DefaultScanService.java:133)
at mobi.inthepocket.android.beacons.ibeaconscanner.handlers.TimeoutHandler$1.run(TimeoutHandler.java:45)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
This is how we init the iBeaconScanner in the service:
@Override
public void onCreate()
{
super.onCreate();
Log.i(TAG, "Beacon service is initializing");
IBeaconScanner.initialize(IBeaconScanner.newInitializer(this).build());
IBeaconScanner.getInstance().setCallback(this);
userStopServiceReceiver = new UserStopServiceReceiver();
registerReceiver(userStopServiceReceiver, new IntentFilter(INTENT_USER_STOP_SERVICE));
}
After a logout the timedOutHandler seems to be called and this triggers a null pointer exception because bluetoothAdapter is null.
The text was updated successfully, but these errors were encountered:
Ventis
changed the title
App crashed when stopping the IBeaconScanner in a service that destroys itself afterwards
App crashes when stopping the IBeaconScanner in a service that destroys itself afterwards
Sep 19, 2017
I understand that the issue is that, when you are inside a beacon, and stop monitoring, that the timeout (to trigger the exit callback) encounters a nullpointer exception as you stopped the service.
I'll have to fix the behavior. When you stop, the exit timeouts should be removed.
Yes, that is correct. Unfortunately it seems to trigger every time on the Android Emulator, causing a crash. Even though we don't start monitoring if EmulatorUtils.isEmulator() is true.
The problem is a simple null pointer exception that only occurs on emulators or more recent Android versions (9+ I suppose) when bluetooth is turned off.
Hi,
I'm using your library in a react-native project where on user logout we want to stop the ibeaconscanner. We do this by sending a broadcast which we catch in a service called BeaconService:
However, not long after logout this crashes the app with the follow error:
This is how we init the iBeaconScanner in the service:
After a logout the timedOutHandler seems to be called and this triggers a null pointer exception because bluetoothAdapter is null.
The text was updated successfully, but these errors were encountered: