I'm trying to listen to Beacons when the app is closed (killed) on Android (swiped off task manager).
I'm using Appcelerator Titanium 5+ and for the beacons using the module https://github.com/dwk5123/android-altbeacon-module. The app works just fine when is on background, but not when you close it. I've tried the Altbeacon.setRunInService() method creating an app service on Titanium and it doesn't seem to work.
I've also tried to modify the module to implement this http://altbeacon.github.io/android-beacon-library/background_launching.html but I'm not able to access the Application class because Titanium is generating it on the build process. If I create an Application class and put it on the manifest it will overwrite my Titanium app Application class and will not run it.
Also, in the module class "AndroidAltbeaconModuleModule" I tried to implement the BootstrapNotifier interface and its methods: didDetermineStateForRegion
, didEnterRegion
and didExitRegion
.
Then on onAppCreate
method tried to implement:
Region region = new Region("My Region", Identifier.parse(
"00000000-0000-0000-0000-000000000001"), null, null);
regionBootstrap = new RegionBootstrap(this, region);
but this
on regionBootstrap
constructor is not static and got an error about it.
Secondly, I tried to create a non-static method and call this code from the module. It successfully listen to BootstrapNotifier events but not if the app is killed, only on background. Is this because the regionBootstrap isn't in the onCreate method of the Application class? I checked this question Using the AltBeacon library without extending Application and this Implementing BootstrapNotifier on Activity instead of Application class as well where davidgyoung (creator of the Altbeacon lib) gave a good answer but not possible (at least for me) to be implemented with Titanium.
Is the only way to notice a beacon with app killed with this Application functionality? I've tried a little to implement a JobService and a BroadcastReceiver in the module but I'm not such a good Java/Android developer and this could take a lot of time. Does anyone have an extra idea? Please share it =)
Thanks in advance!