Altbeacon Android - EnterRegion while app is killed (not background)

I try to listen to Beacons when the application is closed (killed) on Android (task manager is disabled).

I also use Appcelerator Titanium 5+ for beacons using the https://github.com/dwk5123/android-altbeacon-module module. The application works fine when it is in the background, but not when you close it. I tried the Altbeacon.setRunInService () method, creating an application service on Titanium, and it does not seem to work.

I also tried changing the module to implement this http://altbeacon.imtqy.com/android-beacon-library/background_launching.html , but I can’t access the Application Class because Titanium generates it during the build process. If I create an application class and put it in the manifest, it will overwrite my Titanium application application class and will not start it.

In addition, in the module class "AndroidAltbeaconModuleModule", I tried to implement the BootstrapNotifier interface and its methods: didDetermineStateForRegion , didEnterRegion and didExitRegion . Then the 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 a module. It successfully listens for BootstrapNotifier events, but not, if the application is killed, only in the background. Is this because regionBootstrap is not in the onCreate method of the Application class? I checked this question Using the AltBeacon library without the Application extension and Embedding the BootstrapNotifier in the Activity instead of the application class as Well So where davidgyoung (creator of Altbeacon lib) gave a good answer, but not possible (at least for me) to be implemented with Titanium.

The only way to spot a beacon with an app killed with this app functionality? I tried a little to implement JobService and BroadcastReceiver in the module, but I am not such a good Java / Android developer and it can take a lot of time. Anyone have an extra idea? Please share it =)

Thanks in advance!

0
android titanium appcelerator-titanium altbeacon
source share
1 answer

I am not a titanium specialist, but I have two suggestions:

  • Can you create an Application class that extends the one that Titanium created and then modify your AndroidManifest.xml to use your Application class? If you can do this, you can build the RegionBootstrap method in your onCreate class and then call super.onCreate () to execute any titan.

  • The only way to put logic in your "AndroidAltbeaconModuleModule" will work if this module code is executed immediately when the application starts in the background (for example, after receiving RECEIVE_BOOT_COMPLETED when the phone starts). There will be no user interface at this point. If this is really how it works, then it is possible, but you need to somehow access the Android Context object in Titanium and use it to create a new native Java class that implements all BootStrapNotifier methods.

There are always other ways to do this. RegionBootstrap designed to make it relatively painless. If you cannot use it due to the limitations of Titanium, you will need to create part of what it does from scratch, which will no doubt require writing at least the native BroadcastReceiver .

0
source share

All Articles