altbeacon / android-beacon-library Goto Github PK
View Code? Open in Web Editor NEWAllows Android apps to interact with BLE beacons
License: Apache License 2.0
Allows Android apps to interact with BLE beacons
License: Apache License 2.0
I downloaded the binary archive and when I start transmitting beacons from my Mac my Android app crashes with;
D/BtGatt.GattService( 1457): onScanResult() - address=B8:F6:B1:11:A5:6A, rssi=-67
D/BluetoothAdapter(27151): onScanResult() - Device=B8:F6:B1:11:A5:6A RSSI=-67
D/BluetoothAdapter( 4913): onScanResult() - Device=B8:F6:B1:11:A5:6A RSSI=-67
W/QuickConnect( 4913): BleHelper.getSConnectDataFromBLE - can not resolve length info
E/AndroidRuntime(27151): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime(27151): at android.os.AsyncTask$3.done(AsyncTask.java:300)
E/AndroidRuntime(27151): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
E/AndroidRuntime(27151): at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
E/AndroidRuntime(27151): at java.util.concurrent.FutureTask.run(FutureTask.java:242)
E/AndroidRuntime(27151): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
E/AndroidRuntime(27151): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/AndroidRuntime(27151): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/AndroidRuntime(27151): at java.lang.Thread.run(Thread.java:841)
E/AndroidRuntime(27151): Caused by: java.lang.NullPointerException
E/AndroidRuntime(27151): at org.altbeacon.beacon.BeaconParser.fromScanData(BeaconParser.java:244)
E/AndroidRuntime(27151): at org.altbeacon.beacon.BeaconParser.fromScanData(BeaconParser.java:203)
E/AndroidRuntime(27151): at org.altbeacon.beacon.service.BeaconService$ScanProcessor.doInBackground(BeaconService.java:610)
E/AndroidRuntime(27151): at org.altbeacon.beacon.service.BeaconService$ScanProcessor.doInBackground(BeaconService.java:602)
E/AndroidRuntime(27151): at android.os.AsyncTask$2.call(AsyncTask.java:288)
E/AndroidRuntime(27151): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
Here are code snips;
activity = context.getActivity();
verifyBluetooth();
beaconManager = org.altbeacon.beacon.BeaconManager.getInstanceForApplication(activity.getApplicationContext());
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("**THIS STRING REDACTED SEE COMMENT BELOW**"));
beaconManager.bind(this);
....
@OverRide
public boolean bindService(android.content.Intent intent, android.content.ServiceConnection connection, int code) {
Log.d(TAG, "bindService");
Toast.makeText(activity.getApplicationContext(),
"bind service called", Toast.LENGTH_LONG).show();
return activity.getApplicationContext().bindService(intent, connection,code);
}
Hi,
Maybe I am not using the library as intended, but I am having issues with the isBound method.
I am binding to the service using the application context from within a Fragment that is set to retain instance state. If this isn't the correct approach let me know.
The issue I am seeing is that everything appears to work as expected the first time around. I call getInstanceForApplication(applicationContext) in my fragment's onCreate method.
Next I press the back button which calls beaconManager.unbind. The BeaconService logs show "unbinding" and "onDestory called. stopping scanning"
If I relaunch my app it again calls getInstanceForApplication in the fragment's onCreate method. The difference this time is that the serviceMessenger is not null so if I call isBound immediately after Bind, I will get true. Inspecting the mAltBeaconManager reveals that the consumer is there but isConnected is false. We don't appear to have access to the isConnected.
Is this working as intended? It seems to me that one solution could be setting the serviceMessenger to null when the service is destroyed because the last consumer has unboud.
Hi David,
This is not an issue but a request for advice.
I have an indoor locatiion application implemented using WiFi AP locations to determine where a user is. The application uses only the APs' RSSI readings.
I would like to extend the application to use beacons location in the same way I currently use WiFi AP location. This should be possible since using your library I can retrieve a beacon's RSSI level.
To start with I assumeI should add to my application "implements BootstrapNotifier, RangeNotifier" and the related methods (i.e. didEnterRegion, etc., etc.). Is this right?
If my understanding is correct, I should add my application specific code to these methods, right?
However, I wonder whether in my case I should use RegionBootstrap since the core location processing code in my application is a background service. If I were to use RegionnBootstrap would I call it from didEnterRegion? I don't think this is correct but I am not sure where I would call it, at OnCreate time?
Any suggestions would be greatly appreciated. Please let me know what you think and if you need additional information.
Thanks,
Alex Donnini
Hello, I have tried to import the android beacon library a number of times into Eclipse (v4.4) (with gradle plugin latest version installed. Every attempt failed with the error reported below. Please note that the Android support repository and the Android support library are both installed.
Thanks for your help,
Alex Donnini
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Can't get version from git: org.gradle.process.internal.ExecException: Process 'command 'git'' finished with non-zero exit value 128
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'android-beacon-library'.
Could not resolve all dependencies for configuration ':_debugTestCompile'.
Could not find com.android.support:support-v4:19.0.1.
Required by:
org.altbeacon:android-beacon-library:adhoc > org.robolectric:robolectric:2.3
Could not find any version that matches com.android.support:support-v4:19.1.+.
Required by:
org.altbeacon:android-beacon-library:adhoc > com.squareup:fest-android:1.0.8
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 2.348 secs
I'm using almost the latest sources (from Aug 27th) and I'm experiencing this problem, testing with a single beacon. With everything stationary and a while ranging a single monitored region, every couple of minutes I get exit/enter events for it.
Is this a known issue with the library? How can/should I investigate this problem?
Is it possible to access the minor from the beacon that triggered the region event even if that region does not have the minor specified?
I know this works for ranging, but I want to know which beacon triggered the region.
The problem seems to be in the Region(Region otherRegion)
copy constructor:
for (int i = 0; i < otherRegion.mIdentifiers.size(); i++) {
mIdentifiers.add(new Identifier(otherRegion.mIdentifiers.get(i)));
}
This means that for each position that the original region had no identifier, as in the basic example:
new Region("myRangingUniqueId", null, null, null);
the cloned copy (for example, produced when calling startRangingBeaconsInRegion()
) will have an Identifier with a null string instead.
A possible fix would be to change the copying loop into:
for (int i = 0; i < otherRegion.mIdentifiers.size(); i++) {
Identifier otherIdentifier = otherRegion.mIdentifiers.get(i);
mIdentifiers.add(otherIdentifier != null ? new Identifier(otherIdentifier) : null);
}
Hi,
thanks for share this awesome library. I have an issue and I don't know how to fix it.
I implemented a service that it is waked up every 5 mins, bind BeaconManager, start ranging for beacon and after first beacons list is received, I stop ranging and unbind manager.
Everythings works great but randomly BeaconService remains active (I can see it under Settings-Apps->Running) and I obtain always 0 beacons from scan although I have a lot of beacon around me.
If I kill this service from Settings it return to work.
How can I fix it?
Thanks
Giulio
A common project setup problem is to forget to enable manifest merging. This causes the service to not start up.
A way to make this obvious for folks is too detect this automatically using one of the techniques described here: http://stackoverflow.com/questions/6529069/how-to-programmatically-check-if-a-service-is-declared-in-androidmanifest-xml and throw a Runtime exception with instructions on what to do.
Am I doing something wrong?
[janitor@datenhaufen android-beacon-library]$ java -version
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
[janitor@datenhaufen android-beacon-library]$ ./gradlew test
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debugTest as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.3 is ignored for debugTest as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
Creating properties on demand (a.k.a. dynamic properties) has been deprecated and is scheduled to be removed in Gradle 2.0. Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for information on the replacement for dynamic properties.
Deprecated dynamic property: "destinationDir" on "task ':testDebugClasses'", value: "/home/janitor/android-...".
:preBuild
:preDebugBuild
:checkDebugManifest
:prepareDebugDependencies
:compileDebugAidl
:compileDebugRenderscript
:generateDebugBuildConfig
:mergeDebugAssets
:generateDebugResValues
:generateDebugResources
:packageDebugResources
:processDebugManifest
:processDebugResources
:generateDebugSources
:compileDebugJava
Note: /home/janitor/android-beacon-library/src/main/java/org/altbeacon/beacon/service/BeaconService.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:compileTestDebugJava
Note: /home/janitor/android-beacon-library/src/test/java/org/altbeacon/beacon/org/altbeacon/beacon/simulator/BeaconSimulatorTest.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:processTestDebugResources UP-TO-DATE
:testDebugClasses
:testDebug
org.altbeacon.beacon.IdentifierTest > testToStringNormalizesCase FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.IdentifierTest > testEqualsNormalizationIgnoresCase FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.AltBeaconTest > testCanSerializeParcelable FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.AltBeaconTest > testRecognizeBeacon FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.AltBeaconParserTest > testRecognizeBeacon FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.AltBeaconParserTest > testDetectsDaveMHardwareBeacon FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.AltBeaconParserTest > testDetectsAlternateBeconType FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.BeaconTest > testCanSerializeParcelable FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.BeaconTest > testBeaconsWithDifferentId3AreNotEqual FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.BeaconTest > testCalculateAccuracyWithRssiEqualsPower FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.BeaconTest > testCalculateAccuracyWithRssiGreaterThanPower FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.BeaconTest > testCalculateAccuracyWithRssiLessThanPower FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.BeaconTest > testCalculateAccuracyWithRssiEqualsPowerOnInternalProperties FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.BeaconTest > testCalculateAccuracyWithRssiEqualsPowerOnInternalPropertiesAndRunningAverage FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.BeaconTest > testAccessBeaconIdentifiers FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.BeaconTest > testBeaconsWithSameIdentifersAreEqual FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.BeaconTest > testBeaconsWithDifferentId1AreNotEqual FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.BeaconTest > testBeaconsWithDifferentId2AreNotEqual FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.RegionTest > testCanSerializeParcelable FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.RegionTest > testBeaconMatchesRegionWithSameIdentifier1 FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.RegionTest > testBeaconMatchesRegionWithSameIdentifier1And2 FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.RegionTest > testBeaconMatchesRegionWithDifferentIdentifier1 FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.RegionTest > testToString FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.RegionTest > testConvenienceIdentifierAccessors FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.RegionTest > testBeaconMatchesRegionWithSameIdentifiers FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.BeaconParserTest > testRecognizeBeacon FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.BeaconParserTest > testSetBeaconLayout FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.BeaconParserTest > testLongToByteArray FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.BeaconParserTest > testRecognizeBeaconCapturedManufacturer FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.org.altbeacon.beacon.simulator.BeaconSimulatorTest > testSetBeacons FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.org.altbeacon.beacon.simulator.BeaconSimulatorTest > testSetBeaconsEmpty FAILED
java.lang.IllegalArgumentException
org.altbeacon.beacon.org.altbeacon.beacon.simulator.BeaconSimulatorTest > testSetBeaconsNull FAILED
java.lang.IllegalArgumentException
33 tests completed, 32 failed
:testDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':testDebug'.
> There were failing tests. See the report at: file:///home/janitor/android-beacon-library/build/test-report/debug/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 6.596 secs
Hi everyone,
Is it possible to control the amount of time that a device stays in a certain region? I mean, from 'didEnterRegion' to 'didExitRegion' calls, but only for specific regions.
Thanks in advance!
I hate to say, but it does not Android studio beta(0.8.6)
Google changes Gradle quickly and is real a suck. However, since beta version is to indicate it will not change the Gradle rapidly as before, so I believe we should support Android Studio beta.
Hi,
I have read this on StackOverflow :
The app will not be running and cannot auto-launch the Activity.
The app will start scanning for beacons periodically after boot and will launch the Activity when one is detected.
The app will not be running and cannot auto-launch until charger connect/disconnect or reboot. After that time, behavior is as in (2). More details on this case are available here.
And my current behavior is in case (3), and when the app is killed, and the charger is disconnected and reconnected, it doesnt start the app again, nor does it re-detect the beacons.
I looked through the logcat,
10-21 15:00:21.013 W/ActivityManager( 951): Scheduling restart of crashed service /org.altbeacon.beacon.service.BeaconService in 1000ms
10-21 15:00:22.133 I/BeaconService(11088): beaconService version 2.0-beta3 is starting up'
And the logcat stopped showing any more logs from BeaconService.
I just started to play with AltBeacon library. I downloaded sample app from AltBeacon/android-beacon-library-reference and added the library reference to android-beacon-library-2.0.tar.gz . When I ran it on my MX4 device (MeiZu made in China) with Android 4.4, I saw the main activity but it behaved very slow. I clicked start ranging button, the new activity view was not responding as the same; it took many seconds to go back to previous view if I clicked back button. I'm curious about if the library is scanning too much on main thread causing the non-responsiveness, or because it's the device model itself not good fit for the beacon library implementation. Thanks!
ps. I added the iBeacon parser and still didn't see any output in the app, not sure if it's related with the problem above.
I followed the advice from David to enable BeaconManager.setDebug:true
and attached logcat logs especially filtered for verbose, debug and info levels. I clicked "Start Ranging" button about 10:33:00.
https://www.dropbox.com/s/dp41jrq3whzichv/logcat_verbose.txt?dl=0
https://www.dropbox.com/s/8x5shm2o72bpmb6/logcat_debug.txt?dl=0
https://www.dropbox.com/s/f2esuuo6vb72gwd/logcat_error.txt?dl=0
btw, I'm a Android novice. :)
The following scenario triggers in many cases a beacon that should not be ranged, since it is off, to still be reported as being ranged and the distance field of the beacon to be set to NaN. Although, the focus of the scenario is on a particular region/beacon there were other beacons broadcasting that did not match the ranged region at the time when the scenario was executed.
Scenario (Nexus 5 – Android 4.4.2 – AltBeacon 2.0):
Sometimes, continuing with the following steps, the beacon is still ranged when it is off and the distance field of the beacon is set to NaN.
9. Wait till the next scan is performed. At this point, didRangeBeaconsInRegion is invoked with an empty beacons collection.
10. After the waiting for the next Bluetooth scan starts, turn on the beacon.
11. Wait till the next scan is performed. At this point, didRangeBeaconsInRegion is invoked with the beacons collection containing the ranged beacon.
12. After the waiting for the next Bluetooth scan starts, turn off the beacon.
13. Sometimes, after the next background scan, didRangeBeaconsInRegion is invoked with the beacons collection still containing the ranged beacon and the distance field is set to NaN.
Some captured log entries right before didRangeBeaconsInRegion is invoked with the beacon having the distance set to NaN:
D/RangedBeacon(19592): Running average mRssi based on 0 measurements: NaN
D/BeaconService(19592): Calling ranging callback
D/RangedBeacon(19592): calculated new runningAverageRssi:NaN
D/RangeState(19592): Dumping beacon from RangeState because it has no recent measurements.
D/Callback(19592): attempting callback via intent: ComponentInfo{.../org.altbeacon.beacon.BeaconIntentProcessor}
D/RangingData(19592): writing RangingData
D/Beacon(19592): serializing identifiers of size 3
D/CurveFittedDistanceCalculator(19592): calculating distance based on mRssi of NaN and txPower of -57
D/CurveFittedDistanceCalculator(19592): avg mRssi: NaN distance: NaN
D/RangingData(19592): done writing RangingData
...
D/BeaconService(19592): Restarting scan. Unique beacons seen last cycle: 2 Total beacon advertisement packets seen: 14
D/BeaconService(19592): Waiting to start next bluetooth scan for another 60000 milliseconds
D/BeaconParser(19592): index is 0
D/BeaconParser(19592): calculatedValue for position 0 with positionValue 1 and byteValue 88 is 88
D/BeaconParser(19592): index is 1
D/BeaconParser(19592): calculatedValue for position 1 with positionValue 256 and byteValue 2 is 512
D/BeaconParser(19592): Byte array is size 2
D/BeaconIntentProcessor(19592): got an intent to process
D/RangingData(19592): parsing RangingData
D/RangingData(19592): parsing RangingData
D/BeaconParser(19592): index is 0
D/BeaconIntentProcessor(19592): got ranging data
D/BeaconParser(19592): calculatedValue for position 0 with positionValue 1 and byteValue 41 is 41
...
D/MyApp(19592): Discovered beacon: id1: id2: id3: Distance: NaN RSSI: -16
When I query a beacon advertising packet data field on two different devices, I get a different value for the same beacon.
I initialise the beacon...
beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:2-3=redacted,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
and then...
beacon.getDataFields().get(0).byteValue()
which gives me different values.
I am running the same binary on a Nexus 5 and a Motorola Moto G (with wifi switched off) both running Android 4.4.4 and I'm monitoring the same beacon at the same time. I'm using 2.0 AltBeacon library. The beacon is advertising at 1 Hz.
As it goes, byte 25 encodes the battery power level of the beacon. On the moto the byteValue() is returned as 98 and on the nexus 100. But I'm sure what the byte represents is irrelevant.
The only difference I can see is the device itself.
Any ideas?
Hi,
I tried to test how Altbeacon library is reacting when application is killed by user. When a beacon enters the region after killing the application BeaconService throws following exception on Logcat. I am using android-l-apis branch.
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.StackOverflowError: stack size 1036KB
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:76)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java:92)
at org.altbeacon.beacon.service.Stats.newSampleInterval(Stats.java
11-07 02:31:14.261 26524-26548/? D/Error﹕ ERR: exClass=java.lang.StackOverflowError
11-07 02:31:14.261 26524-26548/? D/Error﹕ ERR: exMsg=stack size 1036KB
11-07 02:31:14.261 26524-26548/? D/Error﹕ ERR: file=Stats.java
11-07 02:31:14.261 26524-26548/? D/Error﹕ ERR: class=org.altbeacon.beacon.service.Stats
11-07 02:31:14.261 26524-26548/? D/Error﹕ ERR: method=newSampleInterval line=76
Is it possible to update, say, a beacon's Id2 or Id3 using this library? I've been trying to find a way, but to no avail...
Hi David,
I'm trying to implement a basic iBeacon monitor based off your iBeaconReferenceAndroid example application.
However either the BeaconManager doesn't manage to bind the implemented BeaconConsumer, or the Overrided onBeaconServiceConnect() is never being called.
However when I destroy the activity I get the following LOG, but other than that, nothing:
08-05 12:58:28.260: D/BeaconManager(19022): Unbinding
I've included my code below, just in case I've done something silly, but I think it should be all correct.
Using Eclipse as my IDE, and created the library project using the src, and the files found inside scripts/eclipse-support. Phone is Galaxy S4 running KitKat.
import org.altbeacon.beacon.BeaconConsumer;
import org.altbeacon.beacon.BeaconManager;
import org.altbeacon.beacon.BeaconParser;
import org.altbeacon.beacon.MonitorNotifier;
import org.altbeacon.beacon.Region;
import android.app.Activity;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
public class BeaconActivity extends Activity implements BeaconConsumer {
public static String TAG = "BeaconActivity";
private BeaconManager beaconManager;
private Region region = new Region("myMonitoringUniqueId", null, null, null);
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_beacon);
beaconManager = org.altbeacon.beacon.BeaconManager.getInstanceForApplication(this);
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,d:25-25"));
beaconManager.bind(this);
}
@Override
public void onBeaconServiceConnect() {
Log.i(TAG, "Beacon Service Connected");
beaconManager.setMonitorNotifier(new MonitorNotifier() {
@Override
public void didEnterRegion(Region region) {
Log.i(TAG, "I just saw a beacon named "+ region.getUniqueId() +" for the first time!" );
}
@Override
public void didExitRegion(Region region) {
Log.i(TAG, "I no longer see a beacon named "+ region.getUniqueId());
}
@Override
public void didDetermineStateForRegion(int state, Region region) {
Log.i(TAG, "I have just switched from seeing/not seeing beacons: "+state);
}
});
try {
beaconManager.startMonitoringBeaconsInRegion(region);
} catch (RemoteException e) {
Log.e(TAG, "Remote Exception Error: ");
e.printStackTrace();
}
}
@Override
public void onDestroy(){
super.onDestroy();
beaconManager.unbind(this);
}
}
EDIT:
I set debugging to true inside BeaconManager.java, and it appears to be binding fine.
08-05 13:16:16.802: D/BeaconManager(1494): This consumer is not bound. binding: co.makelight.BeaconActivity@429b8778
08-05 13:16:16.802: D/BeaconManager(1494): consumer count is now:1
Hi,
I'm currently working on a project which requires the use of your library. I developped a service extending BeaconConsumer which runs the ranging process.
The app is running well if I compile it on linux but I don't know why, the app doesn't work anymore when the app is compiled whith Eclipse on Windows.
The logcat displayed is this one :
11-28 18:14:20.909: I/dalvikvm(18349): Failed resolving Lcom/eirb/projets9/scanner/RangingService; interface 772 'Lorg/altbeacon/beacon/BeaconConsumer;'
11-28 18:14:20.909: W/dalvikvm(18349): Link of class 'Lcom/eirb/projets9/scanner/RangingService;' failed
11-28 18:14:20.909: E/dalvikvm(18349): Could not find class 'com.eirb.projets9.scanner.RangingService', referenced from method com.eirb.projets9.MainActivity.onCreate
11-28 18:14:20.909: W/dalvikvm(18349): VFY: unable to resolve const-class 673 (Lcom/eirb/projets9/scanner/RangingService;) in Lcom/eirb/projets9/MainActivity;
11-28 18:14:20.909: D/dalvikvm(18349): VFY: replacing opcode 0x1c at 0x000f
11-28 18:14:20.949: D/AndroidRuntime(18349): Shutting down VM
11-28 18:14:20.949: W/dalvikvm(18349): threadid=1: thread exiting with uncaught exception (group=0x41569ba8)
11-28 18:14:20.959: E/AndroidRuntime(18349): FATAL EXCEPTION: main
11-28 18:14:20.959: E/AndroidRuntime(18349): Process: com.eirb.projets9, PID: 18349
11-28 18:14:20.959: E/AndroidRuntime(18349): java.lang.NoClassDefFoundError: com.eirb.projets9.scanner.RangingService
11-28 18:14:20.959: E/AndroidRuntime(18349): at com.eirb.projets9.MainActivity.onCreate(MainActivity.java:56)
11-28 18:14:20.959: E/AndroidRuntime(18349): at android.app.Activity.performCreate(Activity.java:5231)
11-28 18:14:20.959: E/AndroidRuntime(18349): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
RangingService is my background service started from MainActivity. I have no idea why the app is working diffenrently according to the OS.
Thanks in advance
Update : I can't launch the android-beacon-library-reference neither when I compile it from windows ( no problem with linux )
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'AndroidBeaconLibrary'.
Could not resolve all dependencies for configuration ':_debugTestCompile'.
Could not find any version that matches com.android.support:support-v4:19.1.+.
Required by:
org.altbeacon:AndroidBeaconLibrary:2.0-beta1-2-gfce0d2a > com.squareup:fest-android:1.0.8
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.11 secs
As reported by @jessolo on #47:
InputStream stream = ModelSpecificDistanceCalculator.class.getResourceAsStream("/"+path);
if (stream == null) {
this.getClass().getClassLoader().getResourceAsStream("/"+path);
}
if (stream == null) {
throw new RuntimeException("Cannot load resource at "+path);
}
Pls refer to the code snippet from ModelSpecificDistanceCalculator. It could be a probable miss here. The stream is not assigned when stream is from class loader.Even if the file is readable from classloader stream, it will still throw a RuntimeException.
But the above exception is definitely not because of this. It is possible to load from the web and the file is getting saved. But unable to read from the file.
It appears that as soon as I beaconManager.startRangingBeaconsInRegion, wifi becomes broken on a Moto G. I realise this may be a Moto G thing rather than an AltBeacon thing - but I would be interested to hear your thoughts...
We've been playing with iBeacons on iOS and Android and notice that iBeacons wake iOS devices pretty quickly (a couple seconds), even after long periods of inactivity/sleep, and without a huge battery life hit.
I think Apple may have pushed iBeacon scanning into another chip such that the CPU could sleep while another chip constantly watches for iBeacons/BLE devices.
It sounds like Android L might've added this (or something similar) as well, from this video:
https://www.google.com/events/io/io14videos/0b3fe228-89c5-e311-b297-00155d5066d7
And not just for iBeacons, but all BLE scanning. It looks like the new APIs are in the android.bluetooth.le
package, especially BluetoothLeScanner#startScan (List<ScanFilter> filters, ScanSettings settings, ScanCallback callback)
. ScanSettings
supports a ScanMode
property which can be set to one of:
SCAN_MODE_BALANCED
: Perform Bluetooth LE scan in balanced power mode.SCAN_MODE_LOW_LATENCY
: Scan using highest duty cycle. It's recommended only using this mode when the application is running in foreground.SCAN_MODE_LOW_POWER
: Perform Bluetooth LE scan in low power mode. This is the default scan mode as it consumes the least power.Here's the API of ScanFilter.Builder():
If multiple apps are using this library for beacon-detection in the background they will interfere with each others 5 minute schedule.
Worst case the device will continuously scan for beacons.
A possible "solution" might be to have only one BeaconService running that all the apps will use (using a remote service with aidl?). However in this case the service must be deployed in a separate Beacon-app that the other apps depend on.
What are your thoughts about this?
Quick and obvious question: What's the parsing string for iBeacons?
I'd like to use this library, but I need to support iBeacons as well, and I'm currently using the previous iBeacon library.
I've been testing the android-l branch with my recently updated Nexus 4 and it appears that the scanning still needs to be restarted. After it reports seeing a beacon the first time, it doesn't report it again.
Have you tested the library with this device? Is this something particular for me that I shouldn't be experiencing or is just that the new API is somehow incompatible with the Nexus 4?
Another matter is that I couldn't replicate the results described here http://developer.radiusnetworks.com/2014/10/28/android-5.0-scanning.html regarding the Typical time between detections in the low latency mode, as the detections were nowhere near 100ms for beacons transmitting at 20ms. In many cases, some of the beacons were reported more than a second after started ranging.
Again, since you report different results, I don't know if this situation is particular for this device.
Hi,
this is the problem, I'm facing. I'm using AltBeacon from a class in a library. The class is getting passed a Context element at instantiation. The class implements BeaconConsumer and the overrides are acting like shown below:
@Override
public Context getApplicationContext() {
return mContext.getApplicationContext();
}
@Override
public boolean bindService(Intent intent, ServiceConnection connection, int mode) {
return mContext.bindService(intent, connection, mode);
}
@Override
public void unbindService(ServiceConnection connection) {
mContext.unbindService(connection);
}
@Override
public void onBeaconServiceConnect() {
// do things
}
The bindService works, but because there is no onDestroy in the library (and finalize() is never called either), unbindService will never be called. This leads to the leak mentioned above.
How can I recover from that?
Any pointer welcome.
Regards
In the android-l-apis branch, the backward compatibility for android 4.3 and 4.4 scanning isn't working anymore, the library doesn't start scanning for BLE packets.
I think the bug is in the deferScanIfNeeded method from CycledLeScanner, you might have switched the return true/false statements, at least, this is what I derive from commit 01ea302
Hi
i have a problem with background mode. When i install application on my mobile my app when i go on my home page. But it starts background mode when i plug it into charger...immediately starts scanning ang working in background mode and then i can unplug it and it works. Can you tell me how to fix this isue or somebody else occured this situation ? Also when i tested my app on samsung note 2 and samsung galaxy s3 my app had tendency to kill background mode during few hours. But when i run it on sony xperia sp app does not kill background mode. Som strange behaviour anyway. Can you somehow help me ?
Currently the BeaconService scans every 5 minutes in the background. It "waits" by doing a handler.postDelayed() every second. This mechanism stops when the device enters deep sleep, so it will not detect beacons in that case.
Maybe it is an idea to use the AlarmManager to schedule background-scans in deep sleep?
Build with: Android Studio 0.8.2 and gradle 1.12
What went wrong:
When we import the project from github, a problem occurred after gradle build.
The error said: The project is using an unsupported version of the Android Gradle plug-in (0.10.4)
After change the file"build.gradle" from:
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.10.+'
classpath 'org.robolectric.gradle:gradle-android-test-plugin:0.10.+'
}
to:
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
classpath 'org.robolectric.gradle:gradle-android-test-plugin:0.10.+'
}
Occurred error: Cause: "com.android.build.gradle.AppPlugin"
I want to bind beacon identifying service with my service.
In my service in onStartCommand i have bind beacon service using below command.
beaconManager.bind(this);
But its giving null pointer on 239 no line in this class
https://github.com/AltBeacon/android-beacon-library/blob/master/src/main/java/org/altbeacon/beacon/BeaconManager.java
On description of bind(BeaconConsumer consumer) method you have written below line.
Binds an Android Activity
or Service
to the BeaconService
.
So I am trying to bind your service on my service.
Can you please help me,
The method comment for setBeaconLayout() has an incorrect example:
"m:2-3:beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"
The colon following the "2-3" should be an equals:
"m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"
The missing "i" modifier message incorrectly suggests the "m" modifier and has a typo:
"You must supply a matching beacon type code offset withh a prefix of 'm'"
should read:
"You must supply a matching beacon type code offset with a prefix of 'i'"
It would be an improvement if the method's comment stated that one "m" is required, one "p" is required and at least one "i" is required.
What am I doing wrong? I have 2 Radius Networks beacons sitting on my desk. iOS and the Estimote Android SDK sees them beacons but AltBeacon reports 0 beacons.
07-28 16:56:13.109 3541-3541/com.w I/BeaconService﹕ beaconService version 2.0-beta1-2-gfce0d2a is starting up
07-28 16:56:13.149 3541-3541/com.w I/BeaconService﹕ binding
07-28 16:56:13.279 3541-3541/com.w I/BeaconService﹕ start monitoring received
07-28 16:56:13.319 3541-3541/com.w I/BeaconService﹕ start ranging received
07-28 16:56:14.439 3541-3541/com.w D/Callback﹕ attempting callback via intent: ComponentInfo{com.w/org.altbeacon.beacon.BeaconIntentProcessor}
07-28 16:56:14.469 3541-3853/com.w I/BeaconHelper﹕ Got beacons for ok: []
07-28 16:56:15.569 3541-3541/com.w D/Callback﹕ attempting callback via intent: ComponentInfo{com.w/org.altbeacon.beacon.BeaconIntentProcessor}
07-28 16:56:15.599 3541-3946/com.w I/BeaconHelper﹕ Got beacons for ok: []
07-28 16:56:16.699 3541-3541/com.w D/Callback﹕ attempting callback via intent: ComponentInfo{com.w/org.altbeacon.beacon.BeaconIntentProcessor}
07-28 16:56:16.709 3541-4036/com.w I/BeaconHelper﹕ Got beacons for ok: []
07-28 16:56:17.839 3541-3541/com.w D/Callback﹕ attempting callback via intent: ComponentInfo{com.w/org.altbeacon.beacon.BeaconIntentProcessor}
07-28 16:56:17.849 3541-4089/com.w I/BeaconHelper﹕ Got beacons for ok: []
...
Here's my code:
public class BeaconHelper {
private final Region region = new Region("ok", null, null, null);
private Context context;
private BeaconManager beaconManager;
private ShowController showController;
public BeaconHelper(ShowController showController, Context context) {
this.showController = showController;
this.context = context;
}
public void start() {
beaconManager = BeaconManager.getInstanceForApplication(context);
BeaconManager.getInstanceForApplication(context).bind(new BeaconConsumer() {
@Override
public void onBeaconServiceConnect() {
okStartReally();
}
@Override
public Context getApplicationContext() {
return context.getApplicationContext();
}
@Override
public void unbindService(ServiceConnection serviceConnection) {
context.unbindService(serviceConnection);
}
@Override
public boolean bindService(Intent intent, ServiceConnection serviceConnection, int i) {
return context.bindService(intent, serviceConnection, i);
}
});
}
private void okStartReally() {
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
Log.i("BeaconHelper", "Got beacons for " + region.getUniqueId() + ": " + beacons);
for (Beacon beacon : beacons) {
Log.i("BeaconHelper", "Identifiers: " + beacon.getIdentifiers());
Log.i("BeaconHelper", " ^-- RSSI: " + beacon.getRssi() + " - dist: " + beacon.getDistance());
}
}
});
try {
beaconManager.startMonitoringBeaconsInRegion(region);
beaconManager.startRangingBeaconsInRegion(region);
} catch (RemoteException e) {
Log.e("BeaconHelper", "Error ranging", e);
}
}
public void stop() {
if (beaconManager != null) {
// beaconManager.disconnect();
try {
beaconManager.stopRangingBeaconsInRegion(region);
} catch (RemoteException e) {
Log.e("BeaconHelper", "Error ranging", e);
}
beaconManager = null;
}
}
}
Hi team,
I'm looking got switch from your previous Android iBeacon library to this, but as an Eclipse based developer (at least for now) I need access to the tar file referenced in this text from this project's readme: "Eclipse users may download the latest release binary as a tar.gz file, which may then be imported as an Eclipse Library Project. See the quick start on the project website for more information."
I may just be having a bad day, but I can't find the quick start or the link to the tar file, could you please enlighten me?
Many thanks,
Justin
I have an app which I use to get some adverts from concrete iBeacon. I'm doing it right and the bluetooth works great. The problem is that now I pretend to promt or launch something when the user enters a concrete region having the app in background, so I decided to use AltBeacon lib.
I haven't implemented a service, I just do what the tutorial says to start an activity having the app in background:
http://altbeacon.github.io/android-beacon-library/samples.html
As I see in the example (the last one) what I did was to set the manifest like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.googlebeacon"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name="com.example.googlebeacon.MyRegionApp"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.googlebeacon.MainActivity"
android:label="@string/app_name"
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Once I did that I decided to create another Java class as the advice:
package com.example.googlebeacon;
import org.altbeacon.beacon.BeaconConsumer;
import org.altbeacon.beacon.BeaconManager;
import org.altbeacon.beacon.BeaconParser;
import org.altbeacon.beacon.Identifier;
import org.altbeacon.beacon.RangeNotifier;
import org.altbeacon.beacon.Region;
import org.altbeacon.beacon.powersave.BackgroundPowerSaver;
import org.altbeacon.beacon.startup.BootstrapNotifier;
import org.altbeacon.beacon.startup.RegionBootstrap;
import android.app.Application;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
public class MyRegionApp extends Application implements BootstrapNotifier {
private final String DebugTag="HOLAREGION";
private RegionBootstrap regionBootstrap;
private BackgroundPowerSaver backgroundPowerSaver;
private BeaconManager mBeaconManager;
private static final String UUID = "0112234-4556-6778-899a-abbccddeeff0";
@Override
public void onCreate() {
super.onCreate();
Log.d(DebugTag, "App started up");
//Region region = new Region("allbeacons", null, null, null);
Region region = new Region("allbeacons", Identifier.parse(UUID) , null, null);
backgroundPowerSaver = new BackgroundPowerSaver(this);
regionBootstrap = new RegionBootstrap(this, region);
BeaconManager.getInstanceForApplication(this).getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24"));
// set the duration of the scan to be 1.1 seconds
//mBeaconManager.setBackgroundScanPeriod(1100l);
// set the time between each scan to be 1 minute (60 seconds)
//mBeaconManager.setBackgroundBetweenScanPeriod(60000l);
}
@Override
public void didDetermineStateForRegion(int arg0, Region arg1) {
// TODO Auto-generated method stub
}
@Override
public void didEnterRegion(Region arg0) {
// TODO Auto-generated method stub
Log.d(DebugTag, "Got a didEnterRegion call");
regionBootstrap.disable();
Toast.makeText(getApplicationContext(), "ENTRA EN LA REGION!!!",
Toast.LENGTH_LONG).show();
Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
}
@Override
public void didExitRegion(Region arg0) {
// TODO Auto-generated method stub
Log.d(DebugTag, "Got a didExitRegion call");
}
}
Do I need to call something in the MainActivity or use a service? I'm a bit lost right now.
I don't understand what I'm missing but it never enters in didEnterRegion or in didExitRegion methods, why?
I tried many things into the onCreate methods, here you can see the onCreate with all the commenteds things I tried:
@OverRide
public void onCreate() {
super.onCreate();
Log.d(DebugTag, "App started up");
//BeaconManager beaconManager = BeaconManager.getInstanceForApplication(this);
//BeaconManager.getInstanceForApplication(this).getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24"));
//beaconManager.setBackgroundScanPeriod(1100l);
//beaconManager.setBackgroundBetweenScanPeriod((60000l);
//Region region = new Region("allbeacons", Identifier.parse(UUID) , null, null);
Region region = new Region("allbeacons", null , null, null);
//backgroundPowerSaver = new BackgroundPowerSaver(this);
regionBootstrap = new RegionBootstrap(this, region);
BeaconManager.getInstanceForApplication(this).getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24"));
}
Any help will be very appreciated.
I'm very novice in Android programming, please be a bit patient, I'm doing my best.
Regards.
Iván
Hi~I'm using Nexus 5 to test AltBeacon and I find that the length of byte[] scanRecord is 62. The BLE spec says that max length of advertisement data is 31 bytes. Does it mean that Android ask scan response by default when it is scanning?
Thank you~
I'm trying to change the background between scan period when you're entering / exiting a geofence perimeter to save extra battery life but it seems that changing the scan period while it's running doesn't actually apply.
Is there otherwise a way to turn background on and off as a whole?
Hi
Can i Use it in fragment
If it can how to use
thanks!
Hi, Currently the ModelSpecificDistanceCalculator uses only Nexus 4 and 5. How should I get the coefficients for Samsung devices?
Null pointer exception is randomly raised after executing stop ranging (possibly after stop monitoring as well) when using 2.0-beta3 binary library. This occurs on synchronized (rangeState), line 596, of processBeaconFromScan method from BeaconService.java file. The exception seems to be triggered by a race condition after the region was removed from rangedRegionState map after the region was included in the matchedRegions but before retrieving it from rangedRegionState for the code indicated above. The exception occurs randomly and could be reproduced by executing in a quick succession start/stop ranging/monitoring methods.
Please find below the debug messages captured when the error was reported:
08-20 10:39:23.151: D/BeaconService(22993): beacon detected multiple times in scan cycle :id1: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa id2: 1 id3: 1
08-20 10:39:23.151: D/BeaconService(22993): beacon detected :id1: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa id2: 1 id3: 1
08-20 10:39:23.151: D/BeaconService(22993): looking for ranging region matches for this beacon
08-20 10:39:23.151: D/BeaconService(22993): matches ranging region: id1: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa id2: null id3: null
08-20 10:39:23.151: I/BeaconService(22993): stop ranging received
08-20 10:39:23.151: D/BeaconService(22993): Currently ranging 0 regions.
08-20 10:39:23.151: W/dalvikvm(22993): threadid=24: thread exiting with uncaught exception (group=0x4153bba8)
08-20 10:39:23.151: E/AndroidRuntime(22993): FATAL EXCEPTION: AsyncTask #3
08-20 10:39:23.151: E/AndroidRuntime(22993): Process: …, PID: 22993
08-20 10:39:23.151: E/AndroidRuntime(22993): java.lang.RuntimeException: An error occured while executing doInBackground()
08-20 10:39:23.151: E/AndroidRuntime(22993): at android.os.AsyncTask$3.done(AsyncTask.java:300)
08-20 10:39:23.151: E/AndroidRuntime(22993): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
08-20 10:39:23.151: E/AndroidRuntime(22993): at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
08-20 10:39:23.151: E/AndroidRuntime(22993): at java.util.concurrent.FutureTask.run(FutureTask.java:242)
08-20 10:39:23.151: E/AndroidRuntime(22993): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
08-20 10:39:23.151: E/AndroidRuntime(22993): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
08-20 10:39:23.151: E/AndroidRuntime(22993): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
08-20 10:39:23.151: E/AndroidRuntime(22993): at java.lang.Thread.run(Thread.java:841)
08-20 10:39:23.151: E/AndroidRuntime(22993): Caused by: java.lang.NullPointerException
08-20 10:39:23.151: E/AndroidRuntime(22993): at org.altbeacon.beacon.service.BeaconService.processBeaconFromScan(BeaconService.java:596)
08-20 10:39:23.151: E/AndroidRuntime(22993): at org.altbeacon.beacon.service.BeaconService.access$400(BeaconService.java:64)
08-20 10:39:23.151: E/AndroidRuntime(22993): at org.altbeacon.beacon.service.BeaconService$ScanProcessor.doInBackground(BeaconService.java:617)
08-20 10:39:23.151: E/AndroidRuntime(22993): at org.altbeacon.beacon.service.BeaconService$ScanProcessor.doInBackground(BeaconService.java:602)
08-20 10:39:23.151: E/AndroidRuntime(22993): at android.os.AsyncTask$2.call(AsyncTask.java:288)
08-20 10:39:23.151: E/AndroidRuntime(22993): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
08-20 10:39:23.151: E/AndroidRuntime(22993): ... 4 more
we just have done RSSI measurements on Xiaomi3/2s/4, and want to know how to calculate the coefficient, so that we can add the results to model-distance-calculations.json.
Hi All,
I am not able to resolve BuildConfig file in Design time.
i have created a project in Eclipse.
BeaconService references BuildConfig but not able to resolve that.
import statement says org.altbeacon.beacon.BuildConfig. But i don't see the file inside that.
Is the problem because i don't have gradle enabled which could have resolve this class ?
cheers,
Saurav
Calling BeaconManager.unbind() will work properly in normal case. However when I unplugged USB and then plug it back, onDestroy() log will not show any more.
Use USB and device to run test application
Click unbind from actionbar menu, the service will unbind successfully
D/BeaconManager﹕ Unbinding
I/BeaconService﹕ unbinding
I/BeaconService﹕ onDestroy called. stopping scanning
D/BluetoothAdapter﹕ stopLeScan()
D/BluetoothAdapter﹕ stopLeScan()
Click bind again to re-bind the service
Unplug USB, re-plug it back
Repeat step 2, but now onDestroy will not fired. LeScan will not stop as well
D/BeaconManager﹕ Unbinding
I/BeaconService﹕ unbinding
D/BluetoothAdapter﹕ stopLeScan()
D/BluetoothAdapter﹕ startLeScan(): null
D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=4
D/BluetoothAdapter﹕ onScanResult()
public class MyActivity extends Activity implements BeaconConsumer {
BeaconManager beaconManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
}
@Override
protected void onResume()
{
super.onResume();
beaconManager = BeaconManager.getInstanceForApplication(this);
//Set custom layout
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);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.my, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_bind) {
beaconManager.bind(MyActivity.this);
return true;
}
if (id == R.id.action_unbind) {
beaconManager.unbind(MyActivity.this);
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBeaconServiceConnect() {
try {
beaconManager.startRangingBeaconsInRegion(new Region("Zone", Identifier.parse("887e36a8-3216-48af-8556-ac44dfdf447f"), Identifier.parse("3"), null));
} catch (RemoteException e) {
e.printStackTrace();
}
}
}
Device used in test is Sony Xperia TX running Android 4.3
It would be nice if I could include your library through maven
Hi, I would like to know about the difference between Beacon Monitoring and ranging. In both the cases the scanning is done. If ranging is stopped, will it save up on battery. Also the didRangeBeacons method is getting called multiple times even if the ranging is stopped. Can you pls give a lifecycle approach for didEnterRegion, didExitRegion, didRangeBeaconsInRegion() and onServiceConnect().
I have had this error many times. It happens with the app running and the screen locked about several minutes. Then when I unlocked the screen and tried to use the app I got this error.
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
at java.util.concurrent.FutureTask.run(FutureTask.java:239)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.util.ConcurrentModificationException
at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:573)
at org.altbeacon.beacon.service.BeaconService$ScanProcessor.doInBackground(BeaconService.java:639)
at org.altbeacon.beacon.service.BeaconService$ScanProcessor.doInBackground(BeaconService.java:632)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.