私はアプリケーションを作っています。私はアプリを起動する必要があります。 まあ、私のアプリは半分罰金で動作します....デバイスが地域内にあるとき、アプリは目を覚まします...しかし、デバイスが地域外にあるとき...目を覚ます...私はしませんdidEnterRegionで目が覚めているかどうかを知る。 問題は、デバイスが地域外にあり、アプリが毎回起きているということです。アプリを起動すると、アプリを手動で終了します。起きてください...アプリを手動で閉じる...常にメッセージ付き出口領域...Altbeacon Android、私は目覚めアプリが必要です。デバイスが地域に入る場合
一方、私はdidEnterRegion()を取得し、直後は..didExitRegion ...時々私はdidExitRegionを取得しますが、私は地域にいます...私はプロトコルIBeaconそして、私のデバイスは、Androidで6
私のコードは次のとおりです。
public class Activity extends Application implements BootstrapNotifier,BeaconConsumer,RangeNotifier {..
@Override
public void onCreate() {
super.onCreate();
Log.i(TAG, "App started up");
manager.setAndroidLScanningDisabled(true);
manager.bind(this);
}
@Override
public void onBeaconServiceConnect() {
Log.i(TAG, "Beacon Service Connected");
manager.setBackgroundScanPeriod(3000l);
manager.setBackgroundBetweenScanPeriod(3000l);
manager.setForegroundBetweenScanPeriod(3000l);
manager.setForegroundScanPeriod(3000l);
manager.setDebug(true);
region = new Region("com.example.backgroundRegion",
Identifier.parse("MY UUID"), null, null);
regionBootstrap = new RegionBootstrap(this, region);
manager.getBeaconParsers().add(
new BeaconParser().setBeaconLayout("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24"));
manager.setMonitorNotifier(new MonitorNotifier() {
@Override
public void didEnterRegion(Region region) {
"make my operations...."
}
@Override
public void didExitRegion(Region region) {
}
@Override
public void didDetermineStateForRegion(int state, Region region) {
}
});
manager.addRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion
(Collection<Beacon> collection, Region region) {
Log.i(TAG, "didRangeBeaconsInRegion");
}
});
try {
manager.startMonitoringBeaconsInRegion(region);
manager.startRangingBeaconsInRegion(region);
} catch (RemoteException e) {
Log.e(TAG, "Remote Exception Error: ");
e.printStackTrace();
}
}
@Override
public void didEnterRegion(Region region) {
Log.i(TAG, "BootstrapNotifier didEnterRegion");
}
@Override
public void didExitRegion(Region region) {
Log.i(TAG, "BootstrapNotifier didExitRegion");
}
@Override
public void didDetermineStateForRegion(int i, Region region) {
Log.i(TAG, "BootstrapNotifier didDetermineStateForRegion");
}
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> collection, Region region) {
}
NEW CODE
public class Activity extends Application implements BootstrapNotifier,RangeNotifier {
@Override
public void onCreate() {
super.onCreate();
Log.i(TAG, "App started up");
manager=BeaconManager.getInstanceForApplication(getApplicationContext());
backgroundPowerSaver = new BackgroundPowerSaver(this);
manager.setAndroidLScanningDisabled(true);
manager.setBackgroundScanPeriod(1000l);
manager.setBackgroundBetweenScanPeriod(1000l);
manager.setForegroundBetweenScanPeriod(1000l);
manager.setForegroundScanPeriod(1000l);
manager.setDebug(true);
region = new Region("com.example.backgroundRegion",
Identifier.parse("MY UUID"), null, null);
regionBootstrap = new RegionBootstrap(this, region);
manager.getBeaconParsers().add(
new BeaconParser().setBeaconLayout("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24"));
manager.addRangeNotifier(this);
}
@Override
public void didEnterRegion(Region region) {
Log.i(TAG, "BootstrapNotifier didEnterRegion");
}
@Override
public void didExitRegion(Region region) {
Log.i(TAG, "BootstrapNotifier didExitRegion");
}
@Override
public void didDetermineStateForRegion(int state, Region region) {
Log.i(TAG, "BootstrapNotifier didDetermineStateForRegion"+state);
}
}
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> collection, Region region) {
Log.i(TAG, " BootstrapNotifier didRangeBeaconsInRegion");
}
}
そして、これが私のログです
I/.Activity: App started up
12-22 12:30:49.046 11591-11591/com.myapp W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.
11591-11591/com.myapp I/BeaconService: beaconService version 2.9.2 is starting up
W/BluetoothCrashResolver: Can't read macs from BluetoothCrashResolverState.txt
/com.myapp I/CycledLeScanner: This Android 5.0, but L scanning is disabled. We are using old scanning APIs
/com.myapp W/ModelSpecificDistanceCalculator: Cannot find match for this device. Using default
/com.myapp W/ModelSpecificDistanceCalculator: Cannot find match for this device. Using default
/com.myapp I/BeaconService: starting with intent Intent { cmp=com.myapp/org.altbeacon.beacon.service.BeaconService }
/com.myapp I/BeaconService: binding
/com.myapp I/Adreno: QUALCOMM build : 52af4d2, I8366cd0437
Build Date : 10/20/15
OpenGL ES Shader Compiler Version: XE031.05.13.02
Local Branch : M14
Remote Branch :
Remote Branch :
Reconstruct Branch :
/com.myapp I/OpenGLRenderer: Initialized EGL, version 1.4
/com.myapp I/.IbeaconActivity: BootstrapNotifier didDetermineStateForRegion0
/com.myapp I/BeaconService: start monitoring received
12-22 11:40:29.971 Activity: BootstrapNotifier didDetermineStateForRegion0
12-22 11:40:29.971 Activity: BootstrapNotifier didExitRegion
12-22 11:40:47.050 Activity: BootstrapNotifier didDetermineStateForRegion1
12-22 11:40:47.050 Activity: BootstrapNotifier didEnterRegion
12-22 11:41:17.949 Activity: BootstrapNotifier didDetermineStateForRegion0
12-22 11:41:17.951 Activity: BootstrapNotifier didExitRegion
12-22 11:41:35.074 Activity: BootstrapNotifier didDetermineStateForRegion1
12-22 11:41:35.075 Activity: BootstrapNotifier didEnterRegion
12-22 11:42:07.985 Activity: BootstrapNotifier didDetermineStateForRegion0
12-22 11:42:07.985 Activity: BootstrapNotifier didExitRegion
12-22 11:42:23.094 Activity: BootstrapNotifier didDetermineStateForRegion1
12-22 11:42:23.097 Activity: BootstrapNotifier didEnterRegion
12-22 11:42:51.963 Activity: BootstrapNotifier didDetermineStateForRegion0
12-22 11:42:51.964 Activity: BootstrapNotifier didExitRegion
12-22 11:43:09.041 Activity: BootstrapNotifier didDetermineStateForRegion1
12-22 11:43:09.041 Activity: BootstrapNotifier didEnterRegion
12-22 11:43:39.951 Activity: BootstrapNotifier didDetermineStateForRegion0
12-22 11:43:39.953 Activity: BootstrapNotifier didExitRegion
12-22 11:43:57.085 Activity: BootstrapNotifier didDetermineStateForRegion1
12-22 11:43:57.085 Activity: BootstrapNotifier didEnterRegion
12-22 11:44:29.978 Activity: BootstrapNotifier didDetermineStateForRegion0
12-22 11:44:29.982 Activity: BootstrapNotifier didExitRegion
12-22 11:44:45.082 Activity: BootstrapNotifier didDetermineStateForRegion1
12-22 11:44:45.082 Activity: BootstrapNotifier didEnterRegion
12-22 11:45:17.945 Activity: BootstrapNotifier didDetermineStateForRegion0
12-22 11:45:17.945 Activity: BootstrapNotifier didExitRegion
12-22 11:45:33.067 Activity: BootstrapNotifier didDetermineStateForRegion1
12-22 11:45:33.067 Activity: BootstrapNotifier didEnterRegion
12-22 11:46:01.964 Activity: BootstrapNotifier didDetermineStateForRegion0
12-22 11:46:01.964 Activity: BootstrapNotifier didExitRegion
12-22 11:46:19.028 Activity: BootstrapNotifier didDetermineStateForRegion1
12-22 11:46:19.028 Activity: BootstrapNotifier didEnterRegion
12-22 11:46:49.960 Activity: BootstrapNotifier didDetermineStateForRegion0
12-22 11:46:49.963 Activity: BootstrapNotifier didExitRegion
12-22 11:47:07.035 Activity: BootstrapNotifier didDetermineStateForRegion1
12-22 11:47:07.035 Activity: BootstrapNotifier didEnterRegion
12-22 11:47:37.966 Activity: BootstrapNotifier didDetermineStateForRegion0
12-22 11:47:37.966 Activity: BootstrapNotifier didExitRegion
12-22 11:47:55.057 Activity: BootstrapNotifier didDetermineStateForRegion1
12-22 11:47:55.057 Activity: BootstrapNotifier didEnterRegion
12-22 11:48:27.955 Activity: BootstrapNotifier didDetermineStateForRegion0
12-22 11:48:27.956 Activity: BootstrapNotifier didExitRegion
12-22 11:48:40.995 Activity: BootstrapNotifier didDetermineStateForRegion1
12-22 11:48:40.996 Activity: BootstrapNotifier didEnterRegion
12-22 11:49:11.974 Activity: BootstrapNotifier didDetermineStateForRegion0
12-22 11:49:11.977 Activity: BootstrapNotifier didExitRegion
12-22 11:49:29.048 Activity: BootstrapNotifier didDetermineStateForRegion1
12-22 11:49:29.048 Activity: BootstrapNotifier didEnterRegion
12-22 11:50:01.955 Activity: BootstrapNotifier didDetermineStateForRegion0
12-22 11:50:01.955 Activity: BootstrapNotifier didExitRegion
12-22 11:50:17.075 Activity: BootstrapNotifier didDetermineStateForRegion1
12-22 11:50:17.076 Activity: BootstrapNotifier didEnterRegion
12-22 11:50:49.952 Activity: BootstrapNotifier didDetermineStateForRegion0
12-22 11:50:49.959 Activity: BootstrapNotifier didExitRegion
12-22 11:51:05.098 Activity: BootstrapNotifier didDetermineStateForRegion1
12-22 11:51:05.098 Activity: BootstrapNotifier didEnterRegion
12-22 11:51:33.963 Activity: BootstrapNotifier didDetermineStateForRegion0
12-22 11:51:33.964 Activity: BootstrapNotifier didExitRegion
12-22 11:51:51.045 Activity: BootstrapNotifier didDetermineStateForRegion1
12-22 11:51:51.046 Activity: BootstrapNotifier didEnterRegion
12-22 11:52:21.966 Activity: BootstrapNotifier didDetermineStateForRegion0
12-22 11:52:21.966 Activity: BootstrapNotifier didExitRegion
12-22 11:52:39.054 Activity: BootstrapNotifier didDetermineStateForRegion1
12-22 11:52:39.056 Activity: BootstrapNotifier didEnterRegion
12-22 11:53:11.971 Activity: BootstrapNotifier didDetermineStateForRegion0
12-22 11:53:11.971 Activity: BootstrapNotifier didExitRegion
12-22 11:53:27.067 Activity: BootstrapNotifier didDetermineStateForRegion1
12-22 11:53:27.068 Activity: BootstrapNotifier didEnterRegion
クラスが同時にBeaconConsumerとBootstrapNotifierインターフェイスを実装するために異例である、あなたのデバッグログ
D/BeaconParser: Ignoring pdu type 01
12-22 11:55:37.810 12502-12653/com.myapp D/BeaconParser: Processing pdu type FF: 02011a07ff4c0010020100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 10
12-22 11:55:37.811 12502-12653/com.myapp D/BeaconParser: This is not a matching Beacon advertisement. (Was expecting be ac. The bytes I see are: 02011a07ff4c0010020100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
12-22 11:55:37.811 12502-12653/com.myapp D/BeaconParser: Ignoring pdu type 01
12-22 11:55:37.814 12502-12653/com.myapp D/BeaconParser: Processing pdu type FF: 02011a07ff4c0010020100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 10
12-22 11:55:37.814 12502-12653/com.myapp D/BeaconParser: This is not a matching Beacon advertisement. (Was expecting 4c 00 02 15. The bytes I see are: 02011a07ff4c0010020100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
12-22 11:55:37.923 12502-12502/com.myapp D/CycledLeScanner: Done with scan cycle
12-22 11:55:37.926 12502-12502/com.myapp D/CycledLeScanner: stopping bluetooth le scan
12-22 11:55:37.926 12502-12533/com.myapp D/BluetoothAdapter: stopLeScan()
12-22 11:55:37.926 12502-12502/com.myapp D/CycledLeScanner: Normalizing between scan period from 1000 to 987
12-22 11:55:37.927 12502-12502/com.myapp D/CycledLeScannerForJellyBeanMr2: Waiting to start next Bluetooth scan for another 987 milliseconds
12-22 11:55:37.930 12502-12533/com.myapp D/BluetoothAdapter: STATE_ON
12-22 11:55:38.915 12502-12502/com.myapp D/CycledLeScanner: starting a new scan cycle
12-22 11:55:38.921 12502-12502/com.myapp D/CycledLeScanner: starting a new bluetooth le scan
12-22 11:55:38.923 12502-12533/com.myapp D/BluetoothAdapter: startLeScan(): null
12-22 11:55:38.923 12502-12502/com.myapp D/CycledLeScanner: Waiting to stop scan cycle for another 1000 milliseconds
12-22 11:55:38.924 12502-12502/com.myapp D/CycledLeScanner: Scan started
12-22 11:55:38.927 12502-12533/com.myapp D/BluetoothAdapter: STATE_ON
12-22 11:55:38.935 12502-20381/com.myapp D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=10
12-22 11:55:39.056 12502-12502/com.myapp D/CycledLeScannerForJellyBeanMr2: got record
12-22 11:55:39.057 12502-12661/com.myapp D/BeaconParser: Ignoring pdu type 01
12-22 11:55:39.058 12502-12661/com.myapp D/BeaconParser: Processing pdu type FF: 02011b0bff4c0009060305c0a801660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 14
12-22 11:55:39.059 12502-12661/com.myapp D/BeaconParser: This is not a matching Beacon advertisement. (Was expecting be ac. The bytes I see are: 02011b0bff4c0009060305c0a801660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
12-22 11:55:39.059 12502-12661/com.myapp D/BeaconParser: Ignoring pdu type 01
12-22 11:55:39.060 12502-12661/com.myapp D/BeaconParser: Processing pdu type FF: 02011b0bff4c0009060305c0a801660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 14
12-22 11:55:39.060 12502-12661/com.myapp D/BeaconParser: This is not a matching Beacon advertisement. (Was expecting 4c 00 02 15. The bytes I see are: 02011b0bff4c0009060305c0a801660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
12-22 11:55:39.063 12502-12502/com.myapp D/CycledLeScannerForJellyBeanMr2: got record
12-22 11:55:39.064 12502-12660/com.myapp D/BeaconParser: Ignoring pdu type 01
12-22 11:55:39.065 12502-12660/com.myapp D/BeaconParser: Ignoring pdu type 03
12-22 11:55:39.065 12502-12660/com.myapp D/BeaconParser: No PDUs to process in this packet.
12-22 11:55:39.065 12502-12660/com.myapp D/BeaconParser: Ignoring pdu type 01
12-22 11:55:39.066 12502-12660/com.myapp D/BeaconParser: Ignoring pdu type 03
12-22 11:55:39.066 12502-12660/com.myapp D/BeaconParser: No PDUs to process in this packet.
12-22 11:55:39.088 12502-12502/com.myapp D/CycledLeScannerForJellyBeanMr2: got record
12-22 11:55:39.089 12502-12658/com.myapp D/BeaconParser: Ignoring pdu type 01
12-22 11:55:39.090 12502-12658/com.myapp D/BeaconParser: Processing pdu type FF: 02011a07ff4c0010020100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 10
12-22 11:55:39.091 12502-12658/com.myapp D/BeaconParser: This is not a matching Beacon advertisement. (Was expecting be ac. The bytes I see are: 02011a07ff4c0010020100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
12-22 11:55:39.091 12502-12658/com.myapp D/BeaconParser: Ignoring pdu type 01
12-22 11:55:39.091 12502-12658/com.myapp D/BeaconParser: Processing pdu type FF: 02011a07ff4c0010020100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 10
12-22 11:55:39.092 12502-12658/com.myapp D/BeaconParser: This is not a matching Beacon advertisement. (Was expecting 4c 00 02 15. The bytes I see are: 02011a07ff4c0010020100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
12-22 11:55:39.240 12502-12502/com.myapp D/CycledLeScannerForJellyBeanMr2: got record
12-22 11:55:39.241 12502-12659/com.myapp D/BeaconParser: Ignoring pdu type 01
12-22 11:55:39.243 12502-12659/com.myapp D/BeaconParser: Processing pdu type FF: 02011b0bff4c0009060305c0a801660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 14
12-22 11:55:39.243 12502-12659/com.myapp D/BeaconParser: This is not a matching Beacon advertisement. (Was expecting be ac. The bytes I see are: 02011b0bff4c0009060305c0a801660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
12-22 11:55:39.244 12502-12659/com.myapp D/BeaconParser: Ignoring pdu type 01
12-22 11:55:39.244 12502-12659/com.myapp D/BeaconParser: Processing pdu type FF: 02011b0bff4c0009060305c0a801660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 14
12-22 11:55:39.245 12502-12659/com.myapp D/BeaconParser: This is not a matching Beacon advertisement. (Was expecting 4c 00 02 15. The bytes I see are: 02011b0bff4c0009060305c0a801660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
12-22 11:55:39.273 12502-12502/com.myapp D/CycledLeScannerForJellyBeanMr2: got record
12-22 11:55:39.274 12502-12653/com.myapp D/BeaconParser: Ignoring pdu type 01
12-22 11:55:39.276 12502-12653/com.myapp D/BeaconParser: Processing pdu type FF: 02011a07ff4c0010020100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 10
12-22 11:55:39.277 12502-12653/com.myapp D/BeaconParser: This is not a matching Beacon advertisement. (Was expecting be ac. The bytes I see are: 02011a07ff4c0010020100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
12-22 11:55:39.277 12502-12653/com.myapp D/BeaconParser: Ignoring pdu type 01
12-22 11:55:39.278 12502-12653/com.myapp D/BeaconParser: Processing pdu type FF: 02011a07ff4c0010020100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 10
12-22 11:55:39.279 12502-12653/com.myapp D/BeaconParser: This is not a matching Beacon advertisement. (Was expecting 4c 00 02 15. The bytes I see are: 02011a07ff4c0010020100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
あなたがフォアグラウンドでアプリケーションを実行する場合、ビーコンは常にあるとき、あなたはまた、繰り返し入口/出口のコールバックを得るのですか付近に? – davidgyoung
はい@ davidgyoung ...そして、私はBeaconConsumerインターフェイスを参照するすべてのコードを隠していますし、didRangeBeaconsInRegionメソッドは呼び出されません。 新しいコードと登録で質問を編集しました – AnD
ログには、Bluetoothデバイスが正常に検出されていますが、iBeaconパケットは存在しません。最も簡単な説明は、あなたのビーコンが頻繁に広告をしていないということです。いくつかの安価なビーコンは、バッテリーを節約するために10秒程度しか広告しない。あなたは広告料金を上げることができるかどうかを知りたいかもしれません。 – davidgyoung