Estimote SDK を Android アプリに追加しようとしています。かなり近づいていますが、地域の監視に問題があります。https://github.com/Estimote/Android-SDKにあるGitHub の Estimote Android SDK Guide に従っています。
何らかの理由で、onEnteredRegion および onExitedRegion メソッドがまったく起動していません。アプリが Estimote ビーコンを検出するたびにトリガーするようにしたいと考えています。ありがとう!
ここに私がこれまでに持っているコードがあります。複雑すぎません:
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) {
}
}
}