android - Starting App in background when iBeacon detected -


i experimenting android beacon library , able make working monitoring , ranging apple compatible beacons adding custom parser (see is correct layout detect ibeacons altbeacon's android beacon library?)

now trying write app starts in background using sample code shown here:

http://altbeacon.github.io/android-beacon-library/samples.html

this code:

public class ibeaconbootstrap extends application implements bootstrapnotifier {  private regionbootstrap regionbootstrap;  @override public void oncreate() {      super.oncreate();      log.d("ibeaconbootstrap", "app started up");      // wake app when beacon seen (you can specify specific id     // filers in parameters below)      region region = new region("myregion", null, null, null);     regionbootstrap = new regionbootstrap(this, region); }  @override public void diddeterminestateforregion(int state, region region) {     // don't care      // monitornotifier.inside      log.d("boostrap diddeterminestateforregion", "region " + region.tostring()); }  @override public void didenterregion(region region) {      log.d("boostrap didenterregion", "got didenterregion call");      // call disable make activity below gets     // launched first time beacon seen (until next time app     // launched)     // if want activity launch every single time beacons come     // view, remove call.     regionbootstrap.disable();      intent intent = new intent(this, mainactivity.class);     // important: in androidmanifest.xml definition of activity,     // must set android:launchmode="singleinstance" or 2     // instances     // created when user launches activity manually , gets     // launched here.     intent.setflags(intent.flag_activity_new_task);     this.startactivity(intent); }  @override public void didexitregion(region region) {      log.d("boostrap didexitregion", "got didexitregion call"); } } 

unfortunately, doesn't work. these functions never called:

  • public void diddeterminestateforregion(int arg0, region arg1)
  • public void didenterregion(region arg0)
  • public void didexitregion(region arg0)

i expected @ least diddeterminestateforregion called creating regionbootstrap.

questions:

0) missing?

1) feature work apple compatible ibeacons?

2) have add custom parser? where/how?

thank in advance.

update 0:

following davidgyoung directions got working, changing oncreate function follows:

@override public void oncreate() {      log.d("ibeaconbootstrap", "app started up");      // wake app when beacon seen (you can specify specific id     // filers in parameters below)      region region = new region("myregion", null, null, null);     regionbootstrap = new regionbootstrap(this, region);      beaconmanager.getinstanceforapplication(this).getbeaconparsers().add(new beaconparser().setbeaconlayout("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24"));      super.oncreate(); } 

i have 2 more questions:

0) app checks every 3-5 minutes presence of ibeacons, there way statically or dynamically change interval?

1) apparently, app goes foreground when detects ibeacon if running nothing happens if app not running. expected behavior or app supposed started if not running?

understand out-of-the-box, library works beacons supporting open altbeacon standard. necessary in order keep intellectual property out of open source library. if wish make library work proprietary beacons, must add line oncreate method add different beaconparser instance.

beaconmanager.getinstanceforapplication().getbeaconparsers()   .add(new beaconparser().setbeaconlayout("put-your-parser-expression-here")); 

you need replace string "put-your-parser-expression-here" 1 detect proprietary beacon using. in order find parser expressions various proprietary beacons, try doing google search "getbeaconparser" (include quotes in search.)


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -