altbeacon에서 제공 한 참조 코드를 사용했지만 iBeacons를 감지하지 못했습니다. 다음은 내 코드입니다.altbeacon android 라이브러리에서 iBeacons를 찾을 수 없음
매니페스트에 다음 권한이 포함됩니다. 이 외에도 위치 서비스도 사용할 수있게되었습니다. 활동
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ranging);
beaconManager = BeaconManager.getInstanceForApplication(this);
beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
beaconManager.bind(this);
onBeaconServiceConnecr이 RangeNotifier (아래 코드에서 주석) MoniterNotifier를 모두 사용하여 시도했지만 모두 작동하지 않았다위한
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
에서 onCreate 방법. RangeNotifier는 항상 크기가 0 인 콜렉션을 가지며 MoniterNotifier는 호출되지 않습니다.
@Override
public void onBeaconServiceConnect() {
//BeaconManager beaconManager = BeaconManager.getInstanceForApplication(this);
beaconManager.addRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> collection, Region region) {
if(collection.size() > 0){
for (Beacon beacon : collection) {
Log.i("MainActivity", "I see a beacon that is about "+beacon.getDistance()+" meters away.");
}
}
}
});
/*beaconManager.addMonitorNotifier(new MonitorNotifier() {
@Override
public void didEnterRegion(Region region) {
Log.i(TAG, "I just saw an beacon for the first time!");
}
@Override
public void didExitRegion(Region region) {
Log.i(TAG, "I no longer see an beacon");
}
@Override
public void didDetermineStateForRegion(int state, Region region) {
Log.i(TAG, "I have just switched from seeing/not seeing beacons: "+state);
}
});*/
try {
beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
} catch (RemoteException e) { }
}
감사합니다. 감사합니다.