ibeacon - Receive notification from beacon region detection during background monitoring -
i trying create basic app in create regionbootstrap background monitoring of various types of beacons, in reference app.
however, instead of bringing app foreground upon entering beacon region, display 'you have entered beacon region' local notification.
i presume need coded in oncreate method within 'extends application implements bootstrapnotifier' class. see intent starting main activity instantiated within didenterregion method, in fact i'd need code notification?
the easiest way trigger background notification make custom application
class implements bootstrapnotifier
. put notification code in didenterregion
callback method so:
@override public void didenterregion(region arg0) { notificationcompat.builder builder = new notificationcompat.builder(this) .setcontenttitle("beacon reference application") .setcontenttext("a beacon nearby.") .setsmallicon(r.drawable.ic_launcher); taskstackbuilder stackbuilder = taskstackbuilder.create(this); stackbuilder.addnextintent(new intent(this, monitoringactivity.class)); pendingintent resultpendingintent = stackbuilder.getpendingintent( 0, pendingintent.flag_update_current ); builder.setcontentintent(resultpendingintent); notificationmanager notificationmanager = (notificationmanager) this.getsystemservice(context.notification_service); notificationmanager.notify(1, builder.build()); }
you can see full example of in reference application android beacon library.
Comments
Post a Comment