Comments (10)
Giulio,
Try turning on debug logging for the library with beaconManager.setDebug(true);
Then run your test and capture a LogCat excerpt starting at the time you unbind from the library. Once you have that, please link to a gist of the LogCat excerpt to this thread. Please also annotate in the LogCat excerpt so I know where your service calls unbind.
Thanks,
David
from android-beacon-library.
Thanks for fast answer.
I can try to do this, but the problem is that this behavior is completely random. Some times happens after 4 hours application is running and others after 2 or 8 hours. By the way, tomorrow I will post my service code.
from android-beacon-library.
Understood. Well, one way you could do it is to pipe the LogCat output to
a file, and let your app run overnight.
adb logcat > logfile.txt
Then you could search through the log, figure out where the problem
happened, and share that snippet of the log.
On Mon, Nov 3, 2014 at 5:58 PM, Cromir [email protected] wrote:
Thanks for fast answer.
I can try to do this, but the problem is that this behavior is completely
random. Some times happens after 4 hours application is running and others
after 2 or 8 hours. By the way, tomorrow I will post my service code.—
Reply to this email directly or view it on GitHub
#50 (comment)
.
from android-beacon-library.
OK, this is my Service.
public class Collector extends Service implements BeaconConsumer, RangeNotifier {
private void collectInfo(Context context) {
collectBeaconsAroundInfo();
}
private void collectBeaconsAroundInfo() {
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()) {
BeaconManager manager = BeaconManager.getInstanceForApplication(getApplicationContext());
// This is the pattern for iBeacon. (Code redacted by David Young)
manager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("****** Code Redacted ********"));
// Bind manager
manager.bind(this);
} else {
BeAudience.getInstance().log("Collector -> Bluetooth is not enabled. Turn it on to discover beacons.");
}
}
@Override
public void onBeaconServiceConnect() {
BeAudience.getInstance().log("Collector -> Beacon service connected.");
BeaconManager manager = BeaconManager.getInstanceForApplication(getApplicationContext());
// Set range listener
manager.setRangeNotifier(this);
try {
// Start ranging
manager.startRangingBeaconsInRegion(new Region("BeAudience", null, null, null));
} catch (RemoteException e) {
e.printStackTrace();
//Unbind manager
manager.unbind(this);
}
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
BeAudience.getInstance().log("Collector -> Start new acquisition...");
collectInfo(this);
return START_NOT_STICKY;
}
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
BeaconManager manager = BeaconManager.getInstanceForApplication(this.getApplicationContext());
BeAudience.getInstance().log("Collector -> Beacon found: #" + beacons.size());
try {
// Stop ranging
manager.stopRangingBeaconsInRegion(region);
} catch (RemoteException e) {
e.printStackTrace();
}
//Unbind manager
manager.unbind(Collector.this);
}
}
Every time my service starts, the output in logcat is always this:
11-04 09:45:24.599 28640-28640/com.beintoo.audbeta I/BeAudience﹕ Collector -> Start new acquisition...
11-04 09:45:28.129 28640-28640/com.beintoo.audbeta I/BeaconService﹕ beaconService version 2.0 is starting up
11-04 09:45:28.129 28640-28640/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 09:45:28.129 28640-28640/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 09:45:28.129 28640-28640/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 09:45:28.129 28640-28640/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 09:45:28.129 28640-28640/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 09:45:28.129 28640-28640/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 09:45:28.129 28640-28640/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 09:45:28.129 28640-28640/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 09:45:28.129 28640-28640/com.beintoo.audbeta I/BeaconService﹕ binding
11-04 09:45:28.139 28640-28640/com.beintoo.audbeta I/BeAudience﹕ Collector -> Beacon service connected.
11-04 09:45:28.139 28640-28640/com.beintoo.audbeta I/BeaconService﹕ start ranging received
11-04 09:45:28.139 28640-28640/com.beintoo.audbeta D/BluetoothAdapter﹕ startLeScan(): null
11-04 09:45:28.139 28640-28651/com.beintoo.audbeta D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
11-04 09:45:29.239 28640-28640/com.beintoo.audbeta D/Callback﹕ attempting callback via intent: ComponentInfo{com.beintoo.audbeta/org.altbeacon.beacon.BeaconIntentProcessor}
11-04 09:45:29.249 28640-28640/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()
11-04 09:45:29.259 28640-28640/com.beintoo.audbeta D/BluetoothAdapter﹕ startLeScan(): null
11-04 09:45:29.269 28640-28652/com.beintoo.audbeta D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
11-04 09:45:29.289 28640-28849/com.beintoo.audbeta I/BeAudience﹕ Collector -> Beacon found: #4
11-04 09:45:29.439 28640-28640/com.beintoo.audbeta I/BeaconService﹕ stop ranging received
11-04 09:45:29.439 28640-28849/com.beintoo.audbeta D/BeaconManager﹕ Unbinding
11-04 09:45:29.439 28640-28640/com.beintoo.audbeta I/BeaconService﹕ unbinding
11-04 09:45:29.449 28640-28640/com.beintoo.audbeta I/BeaconService﹕ onDestroy called. stopping scanning
11-04 09:45:29.449 28640-28640/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()
11-04 09:45:29.459 28640-28640/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()
When BeaconService remains active, I obtain exactly the same log except for this line:
11-04 09:45:29.289 28640-28849/com.beintoo.audbeta I/BeAudience﹕ Collector -> Beacon found: #0
in which I obtain always 0 beacons.
Thanks
from android-beacon-library.
It's happened now. Following last 3 execution:
Nothing to notice here, everything is ok.
11-04 10:47:16.119 29456-29456/com.beintoo.audbeta I/BeAudience﹕ Collector -> Start new acquisition...
11-04 10:47:19.559 29456-29456/com.beintoo.audbeta I/BeaconService﹕ beaconService version 2.0 is starting up
11-04 10:47:19.619 29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:19.619 29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:19.619 29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:19.619 29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:19.619 29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:19.619 29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:19.619 29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:19.619 29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:19.619 29456-29456/com.beintoo.audbeta I/BeaconService﹕ binding
11-04 10:47:19.619 29456-29456/com.beintoo.audbeta I/BeAudience﹕ Collector -> Beacon service connected.
11-04 10:47:19.619 29456-29456/com.beintoo.audbeta I/BeaconService﹕ start ranging received
11-04 10:47:19.629 29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ startLeScan(): null
11-04 10:47:19.629 29456-29683/com.beintoo.audbeta D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
11-04 10:47:20.729 29456-29456/com.beintoo.audbeta D/Callback﹕ attempting callback via intent: ComponentInfo{com.beintoo.audbeta/org.altbeacon.beacon.BeaconIntentProcessor}
11-04 10:47:20.729 29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()
11-04 10:47:20.739 29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ startLeScan(): null
11-04 10:47:20.739 29456-29467/com.beintoo.audbeta D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
11-04 10:47:20.739 29456-6868/com.beintoo.audbeta I/BeAudience﹕ Collector -> Beacon found: #5
11-04 10:47:20.959 29456-6868/com.beintoo.audbeta D/BeaconManager﹕ Unbinding
11-04 10:47:20.959 29456-29456/com.beintoo.audbeta I/BeaconService﹕ stop ranging received
11-04 10:47:20.969 29456-29456/com.beintoo.audbeta I/BeaconService﹕ unbinding
11-04 10:47:20.999 29456-29456/com.beintoo.audbeta I/BeaconService﹕ onDestroy called. stopping scanning
11-04 10:47:20.999 29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()
11-04 10:47:20.999 29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()
Here starts issue: beaconService is started before my service bind it: "beaconService version 2.0 is starting up" is printed before "Start new acquisition".
11-04 10:47:49.759 29456-29461/com.beintoo.audbeta D/dalvikvm﹕ Debugger has detached; object registry had 1 entries
11-04 10:47:51.359 29456-29456/com.beintoo.audbeta I/BeaconService﹕ beaconService version 2.0 is starting up
11-04 10:47:51.369 29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:51.369 29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:51.369 29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:51.369 29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:51.369 29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:51.369 29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:48:16.109 29456-29456/com.beintoo.audbeta I/BeAudience﹕ Collector -> Start new acquisition...
11-04 10:48:19.489 29456-29456/com.beintoo.audbeta I/BeaconService﹕ binding
11-04 10:48:19.489 29456-29456/com.beintoo.audbeta I/BeAudience﹕ Collector -> Beacon service connected.
11-04 10:48:19.489 29456-29456/com.beintoo.audbeta I/BeaconService﹕ start ranging received
11-04 10:48:19.489 29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ startLeScan(): null
11-04 10:48:19.489 29456-29683/com.beintoo.audbeta D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
11-04 10:48:20.599 29456-29456/com.beintoo.audbeta D/Callback﹕ attempting callback via intent: ComponentInfo{com.beintoo.audbeta/org.altbeacon.beacon.BeaconIntentProcessor}
11-04 10:48:20.599 29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()
11-04 10:48:20.609 29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ startLeScan(): null
11-04 10:48:20.609 29456-29467/com.beintoo.audbeta D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
11-04 10:48:20.619 29456-7228/com.beintoo.audbeta I/BeAudience﹕ Collector -> Beacon found: #5
11-04 10:48:20.729 29456-7228/com.beintoo.audbeta D/BeaconManager﹕ Unbinding
11-04 10:48:20.729 29456-29456/com.beintoo.audbeta I/BeaconService﹕ stop ranging received
11-04 10:48:20.809 29456-29456/com.beintoo.audbeta I/BeaconService﹕ unbinding
11-04 10:48:21.719 29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()
And consequently in next acquisition, beaconServer doesn't start and beacon detected is 0 forever.
In Settings now I can see beaconService running.
11-04 10:49:19.029 29456-29456/com.beintoo.audbeta I/BeAudience﹕ Collector -> Start new acquisition...
11-04 10:49:22.609 29456-29456/com.beintoo.audbeta I/BeAudience﹕ Collector -> Beacon service connected.
11-04 10:49:22.609 29456-29456/com.beintoo.audbeta I/BeaconService﹕ start ranging received
11-04 10:49:22.609 29456-29456/com.beintoo.audbeta I/BeaconService﹕ Adjusted scanStopTime to be Tue Nov 04 10:48:21 CET 2014
11-04 10:49:23.609 29456-29456/com.beintoo.audbeta D/Callback﹕ attempting callback via intent: ComponentInfo{com.beintoo.audbeta/org.altbeacon.beacon.BeaconIntentProcessor}
11-04 10:49:23.629 29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()
11-04 10:49:23.629 29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ startLeScan(): null
11-04 10:49:23.649 29456-29468/com.beintoo.audbeta D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
11-04 10:49:23.659 29456-7317/com.beintoo.audbeta I/BeAudience﹕ Collector -> Beacon found: #0
11-04 10:49:23.789 29456-29456/com.beintoo.audbeta I/BeaconService﹕ stop ranging received
11-04 10:49:23.789 29456-7317/com.beintoo.audbeta D/BeaconManager﹕ Unbinding
11-04 10:49:24.759 29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()
Thanks
Giulio
from android-beacon-library.
Problem solved.
Every time device was connected/disconnected to a cable, BeaconService restarts.
Thanks for your time.
Giulio
from android-beacon-library.
Giulio, are you using the RegionBootstrap class? If so, this would cause the behavior you mention.
from android-beacon-library.
Actually no.
from android-beacon-library.
Looking more at this issue, it appears that the onBeaconServiceConnect() callback is not made in step 4 if the following sequence occurs:
- application binds to service (service starts)
- application unbinds from service (service stops)
- charger connected/disconnected (service starts)
- application binds to service
A solution to this is to update the BeaconManager to set the connection to the beacon service to null in step 2, and then recreate it in step 4, thereby ensuring a callback.
Attempted fix in 27d48f66a31598a375397ad8fc1b7aed20d03e48
from android-beacon-library.
@Cromir, this fix has been put in the 2.1 beta releases if you would like to see if this resolves your issue.
from android-beacon-library.
Related Issues (20)
- No beacons after locked screen HOT 21
- Cannot parse iBeacons HOT 3
- BeaconService.startForegroundIfConfigured HOT 12
- TargetSdk 34 (android 14) Beacon foreground service no longer working due to new Google restriction HOT 1
- Do we have sample app to implement the library including the operation running in Background HOT 4
- Only a maximum of 2 beacons can be received at a time HOT 1
- java.io.FileNotFoundException android-distance.json HOT 3
- android-distance.json database not found
- Crash when parsing _lengthy_ beacon data fields HOT 3
- Custom Distance calculator is being overwritten HOT 6
- Samsung devices not detecting beacons by intent after first screen off HOT 1
- Can we use this with tauri mobile? HOT 3
- Main thread can be blocked sometimes
- Android 14 didDetermineStateForRegion no beacon is detected or scanned HOT 2
- https://s3.amazonaws.com/android-beacon-library/android-distance.json,This network requests security questions.
- ScanJob restarts scanning every time on navigation HOT 2
- Beacon Not Detected by AltBeacon Library
- altbeacon does not detect beacon devices on Android 12 and later HOT 10
- altbeacon enforces 15 min backgroundBetweenScanPeriod on android 8+
- when the user puts the app to background and then foreground more than 5 times within 30 seconds, app gets "scanning too frequently error" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-beacon-library.