Как заставить библиотеку BootstrapRegion библиотеки AltBeacon распознавать макет iBeacon?
Я использую ссылку,http://altbeacon.github.io/android-beacon-library/samples.html , Я также использовалКак определить регион входа / выхода для нескольких маяков, используя AltBeacon android-beacon-library?
Я пытаюсь обнаружить iBeacon в фоновом режиме, используя Android-Beacon-Library от AltBeacon. Я включил следующий фрагмент кода из моего проекта. До сих пор я не обнаруживаю ibeacons на заднем плане ... любая помощь приветствуется
Я использую BeaconManager для
setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
Тем не менее, я не получаю ошибку и не обнаружение маяка. При запуске приложения в режиме отладки на устройстве Samsung Galaxy 4 приложение запускается, но не обнаруживает активные маяки. Мои маяки - это маяки Rad, которые настроены как iBeacons. Приложение Rad Beacon обнаруживает их, как и мое другое приложение библиотеки AltBeacon, которое работает на переднем плане и обнаруживает мои iBeacons. Эти приложения работают на Samsung Galaxy 4.
Приложение, которое я настроил для фонового обнаружения маяков ... не обнаруживает iBeacons.
Вот мой код Ссылка на Constants.java - это просто файл констант для моего приложения.
package com.myApp.BTleDemo;
import android.app.Application;
import android.content.Intent;
import android.util.Log;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import org.altbeacon.beacon.startup.BootstrapNotifier;
import org.altbeacon.beacon.startup.RegionBootstrap;
import org.altbeacon.beacon.Region;
import org.altbeacon.beacon.BeaconConsumer;
import org.altbeacon.beacon.BeaconManager;
import org.altbeacon.beacon.BeaconParser;
import org.altbeacon.beacon.MonitorNotifier;
import org.altbeacon.beacon.RangeNotifier;
import org.altbeacon.beacon.Region;
import org.altbeacon.beacon.Identifier;
public class BackgroundMode extends Application implements BootstrapNotifier{
private static final String TAG = ".BackgroundMode";
private RegionBootstrap regionBootstrap;
private BeaconManager beaconManager;
SharedPreferences prefs;
List<Region> regions;
public void onCreate() {
super.onCreate();
Log.d(TAG, "App started up");
beaconManager = BeaconManager.getInstanceForApplication(this);
// Add AltBeacons Parser for iBeacon
beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
// wake up the app when any beacon is seen (you can specify specific id filers in the parameters below)
Region region = new Region("com.myApp.BTleDemo.boostrapRegion", Identifier.parse(Constants.BT_UUID),
Identifier.fromInt(Constants.BT_MAJOR), Identifier.fromInt(Constants.BT_MINOR));
regionBootstrap = new RegionBootstrap(this, region);
}
@Override
public void didDetermineStateForRegion(int arg0, Region arg1) {
// Don't care
}
@Override
public void didEnterRegion(Region arg0) {
Log.d(TAG, "Got a didEnterRegion call");
// This call to disable will make it so the activity below only gets launched the first time a beacon is seen (until the next time the app is launched)
// if you want the Activity to launch every single time beacons come into view, remove this call.
regionBootstrap.disable();
Intent intent = new Intent(this, MainActivity.class);
// IMPORTANT: in the AndroidManifest.xml definition of this activity, you must set android:launchMode="singleInstance" or you will get two instances
// created when a user launches the activity manually and it gets launched from here.
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
}
@Override
public void didExitRegion(Region arg0) {
// Don't care
}
/*
@Override
public void onBeaconServiceConnect() {
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
if (beacons.size() > 0) {
Log.i(TAG, "The first beacon I see is about "+beacons.iterator().next().getDistance()+" meters away.");
}
}
});
try {
beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
} catch (RemoteException e) { }
}
}
*/
}
Я не получаю никакого обнаружения ibeacon. Ни один из ожидаемых списков LogCat не опубликован. Я пропустил какой-то шаг?