내 Android 앱에 Estimote SDK를 추가하려고합니다. 꽤 가까워지고 있지만 지역을 모니터링하는 데 문제가 있습니다. GitHub에서 Estimote Android SDK Guide를 따르고 있습니다 (https://github.com/Estimote/Android-SDK).Android Estimote 지역 모니터링
어떤 이유로, onEnteredRegion 및 onExitedRegion 메소드가 전혀 실행되지 않습니다. 나는 그들이 앱이 Estimote 신호를 볼 때마다 트리거하도록하고 싶다. 감사!
여기에 제가 지금까지 가지고있는 코드가 있습니다. 너무 복잡 아무것도 : 당신은 또한 더 이상 필요한 경우 예를 들어, BeaconManager에서 분리하지에 대해 기억해야 할
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override
public void onServiceReady() {
try {
beaconManager.startMonitoring(region);
} catch (RemoteException e) {
Log.d(TAG, "Error while starting monitoring");
}
}
:
public class MainActivity extends Activity {
private static final Region ALL_ESTIMOTE_BEACONS = new Region("regionId", "B9407F30-F5F8-466E-AFF9-25556B57FE6D", null, null);
BeaconManager beaconManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
beaconManager = new BeaconManager(this);
beaconManager.setBackgroundScanPeriod(TimeUnit.SECONDS.toMillis(1), 0);
beaconManager.setMonitoringListener(new MonitoringListener() {
@Override
public void onEnteredRegion(Region region, List<Beacon> beacons) {
builder.setTitle("Entered Region")
.setMessage("")
.setNeutralButton("OK", null);
AlertDialog dialog = builder.create();
dialog.show();
}
@Override
public void onExitedRegion(Region region) {
builder.setTitle("Exited Region")
.setMessage("")
.setNeutralButton("OK", null);
AlertDialog dialog = builder.create();
dialog.show();
}
});
}
protected void onStart() {
super.onStart();
try {
beaconManager.startMonitoring(ALL_ESTIMOTE_BEACONS);
}
catch (RemoteException e) {
}
}
}
이것이 작동합니까 ?? – prabhakaran