chrisriesgo / Android-AltBeacon-Library

Proximity beacon ranging and monitoring library for Xamarin.Android apps
Apache License 2.0
41 stars 44 forks source link

Monitoring as background service sample #17

Open dinonovak opened 8 years ago

dinonovak commented 8 years ago

Hello Chris,

I am stugling in finding the way how to do beacon monitoring in the background when app is closed. Is this supportted by the library now or there are some examples that you can point me to.

Here is the striped down sample that I built from your sample, but I am unable to get monitoring (region entered / left) if the app was killed in task manager. I can see app in the background processes running as a cached background process.

thank you, DiNo

dinonovak commented 8 years ago

I am running it on Android 4.4 - HTC 320 device.

chrisriesgo commented 8 years ago

Hi @dinonovak. I'm pretty sure I had a test example working - somewhere. Whether I ever posted it or not (and whether it still works) is a different issue :)

I'm unavailable the next few days, but I'd like to look into some of these issues this coming week. Maybe an answer by the end of next week?

dinonovak commented 8 years ago

HI @chrisriesgo, thank you or your support and effort. Fed ways will not make a difference, but fresh look onto things will certainly help as I seems to be stuck.

D

chrisriesgo commented 8 years ago

@dinonovak -- are you using my Classic Android example or the Xamarin.Forms example that I have on this repo?

chrisriesgo commented 8 years ago

@dinonovak - my Classic Android example works in the background as-is, but it wouldn't be apparent because of a bug in my code. I just pushed some cleanup code, so you should see beacons listed in a list (they just won't be cleaned up right now when beacons go out of range).

How to test:

  1. Deploy the sample app to device
  2. Using the device Recent Apps, close the sample app -- swipe it away / out of memory
  3. service should still be alive / listening in the background
  4. Plug phone up to power -- this triggers the ACTION_POWER_CONNECTED intent to be broadcast which is handled by the service and wakes up the beacon monitor
  5. Put beacon in range
  6. Now that the beacon monitor is listening (even in the background), as soon as a beacon comes into range, the app will wake up and show the beacon in the list

image

Basically this means that with the app installed, anytime the phone reboots, power is connected or disconnected, the service will wake up (if it stopped) and be listening for beacons in the background.

dinonovak commented 8 years ago

@chrisriesgo, Chris thank you for your support, I am currently traveling but by the end of the week I will try it and provide feedback on the status.

Regards, D

dinonovak commented 8 years ago

HI @chrisriesgo,

here is the troubleshooting that i have done:

1) Sample App (Android only) downloaded and installed 2) When the app is running I can see the beacons 3) I force stop the app / app is not visible in the process list 4) unplug power App jumps in the foreground and starts ranging

SO FINALY ALL IS GOOD !!!

dinonovak commented 8 years ago

Hi @chrisriesgo

I did the following test:

Just a final confirmation, without beacons, app is not jumping in the foreground. Also if beacon is not visible immediatelly after app is started it takes some time for app to wake up !

So, this is pretty much the desired behaviour.

In the native app you have main activity as IBeaconConsumer Any beacon related activity triggers UpdateDisplay, which is then waked up on uiThread, so this is why app jumps in the foreground ?

Can I trouble you for some hints how to get this behaviour in Forms app. I do not need to have app waking up in the foreground, I just need to have ability to send REST call to web service, then I can send push notification and wake up app if needed.

Thanx, D

Suppiej commented 7 years ago

Hi Chris, i don't understand where android receiver is... i cannot find it on your app. can you help me?

thank you