0

I am getting same issue even after setting the scan interval didExitRegion is never called. I am using eddystone google beacon on Android and I am running beacon scanning function in android service. My code for beacon is like below:

Beacon initialization

mBeaconManager = BeaconManager.getInstanceForApplication(this.getApplicationContext());
// Detect the main Eddystone-UID frame:
mBeaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("s:0-1=feaa,m:2-2=10,p:3-3:-41,i:4-21v"));
mBeaconManager.setBackgroundScanPeriod(1000l);
mBeaconManager.setBackgroundBetweenScanPeriod(3000l);
mBeaconManager.bind(this);

didEnterRegion

url = UrlBeaconUrlCompressor.uncompress(region.getId1().toByteArray());
Log.d("radbeacon", "Beacon detected with namespace id " + region.getId1() + " and instance id: " + url);

didExitRegion

url = UrlBeaconUrlCompressor.uncompress(region.getId1().toByteArray());
Log.d("radbeacon", "Beacon out of region with namespace id " + region.getId1() + " and instance id: " + url);
  • Actually by mistake I sent like above. It should be as below: didExitRegion is not called even after setting the scan interval didExitRegion is never called. I am using eddystone google beacon on Android and I am running beacon scanning function in android service. My code for beacon is like above code. – Awadhesh Maurya Sep 12 '16 at 16:40
  • Which device are you using? – Alok Kulkarni Sep 12 '16 at 16:45
  • Everytime didEnterRegion is called successfully at boot phone boot-up or starting app. Only problem with didExitRegion which never called after switched off beacon or went outside of region – Awadhesh Maurya Sep 12 '16 at 16:46
  • Samsung One+ adroid 5.1 – Awadhesh Maurya Sep 12 '16 at 16:47
  • I know this is not exactly what you want but may help you. Did you check this https://googleweblight.com/?lite_url=https://github.com/AltBeacon/android-beacon-library/issues/27&ei=dnyQRBG4&lc=en-IN&s=1&m=713&host=www.google.co.in&ts=1473699023&sig=AKOVD641c5nDm1z4vp3arZTAsQkc0a_y9A – Alok Kulkarni Sep 12 '16 at 16:58
  • The issue may have to do with the lifecycle of your service. Are you sure it is still running when the exit comes? It's hard to give a good answer for what might cause the callback from not getting called, because not all of the code is shown. For example, do you set up a MonitorNotifier to get the callbacks or are you using a RegionBootstrap? If you can show this code it might help find the answer. – davidgyoung Sep 12 '16 at 17:18
  • I am using MonitorNotifier public class PingService extends IntentService implements BeaconConsumer, MonitorNotifier; and calling servise from UI activity by startService(mServiceIntent) and get in service by protected void onHandleIntent(Intent intent). I am not able to paste all code here but there may be chance of service is not running in background, I dont know how to ensure to run service. Can you please provide some sample example or link. – Awadhesh Maurya Sep 13 '16 at 02:00
  • You are absolutely right I have run my app in UI/foreground only found that it is calling didExitRegion on every power off of beacon and on power resume call didEnterRegion and so on. I found some idea of returning START_STICKY from onStartCommand method. Using this method also getting didExitRegion/didEnterRegion on debugging. But when close the app; app getting crashe and shows Unfortunetaly app has stopped. – Awadhesh Maurya Sep 13 '16 at 15:42
  • After making service to run in foreground its running always but phone shows my app is running on screening and asking user to force stop or uninstall on bootup, from sleep to active etc. Really it is irritating for user. Hence I want to implement it like messaging apps like whatsup/email apps notification. – Awadhesh Maurya Sep 20 '16 at 04:19

0 Answers0