Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions android/src/main/java/com/lg2/eddystone/EddystoneModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.facebook.react.bridge.Arguments;
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;

import android.Manifest;
import android.content.*;
import android.bluetooth.*;
import android.bluetooth.le.*;
Expand Down Expand Up @@ -203,6 +202,11 @@ public void handleResult(ScanResult result) {
if (serviceData == null || serviceData.length == 0) {
serviceData = result.getScanRecord().getServiceData(CONFIGURATION_UUID);

WritableMap newParams = Arguments.createMap();
newParams.putString("error", "Connecting beacon");

emit("onUIDFrame", newParams);

if (serviceData == null) {
return;
}
Expand Down Expand Up @@ -290,16 +294,6 @@ public void startScanning() {

ScanSettings settings = new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();

getCurrentActivity().requestPermissions(
new String[]{Manifest.permission.ACCESS_COARSE_LOCATION},
1
);

getCurrentActivity().requestPermissions(
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
1
);

if (!bluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
getCurrentActivity().startActivityForResult(enableBtIntent, 8123);
Expand All @@ -318,7 +312,9 @@ public void startScanning() {
*/
@ReactMethod
public void stopScanning() {
scanner.stopScan(scanCallback);
scanner = null;
if(scanner != null) {
scanner.stopScan(scanCallback);
scanner = null;
}
}
}