Sam Sam - 1 month ago 12
Android Question

how to use radiusnetworks proximity kit to show an alert when user enter the one of the Geofence Map Region

I'm trying to integrate the radiusnetworks proximity kit for my android app, I've already created an account on the radiusnetworks and have created kit with 8 Geofence Map Regions 1 Beacon Regions.

how can i configure my android app to alert the user when he enter the one of the Geofence Map Region configured in my radiusnetworks account.

Thanks

UPDATED:
Stack trace
10-31 09:08:02.567 29104-29160/com.appmajik E/Parcelīš• Class not found when unmarshalling:

org.altbeacon.beacon.service.StartRMData
java.lang.ClassNotFoundException: org.altbeacon.beacon.service.StartRMData
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:251)
at android.os.Parcel.readParcelableCreator(Parcel.java:2142)
at android.os.Parcel.readParcelable(Parcel.java:2106)
at android.os.Message.readFromParcel(Message.java:547)
at android.os.Message.access$000(Message.java:32)
at android.os.Message$1.createFromParcel(Message.java:504)
at android.os.Message$1.createFromParcel(Message.java:501)
at android.os.IMessenger$Stub.onTransact(IMessenger.java:51)
at android.os.Binder.execTransact(Binder.java:412)
at dalvik.system.NativeStart.run(Native Method)


UPDATE

jdk1.7.0_51

proximitykit-android-0.2.0
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
}
I'm using a Physical device

Answer

On the Radius Networks download page (after you've logged into their site - not the github repo), there are detailed instructions for setting up geofences. The short version is:

  • Configure Google Play services for your app based on either the your usage of Eclipse or Android Studio: https://developer.android.com/google/play-services/setup.html#Setup

  • Ensure you're set the proper permissions in your manifest:

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

  • Verify Google Play services support in your app

    Check for Google Play support. For the most recent suggestions by Google, please refer to the Android documentation on checking for Google Play services support.

    Because each app uses Google Play services differently, it's up to you [the app developer] decide the appropriate place in your app to check verify the Google Play services version. For example, if Google Play services is required for your app at all times, you might want to do it when your app first launches. On the other hand, if Google Play services is an optional part of your app, you can check the version only once the user navigates to that portion of your app.

    To verify the Google Play services version, call isGooglePlayServicesAvailable(). If the result code is SUCCESS, then the Google Play services APK is up-to-date and you can continue to make a connection. If, however, the result code is SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED, or SERVICE_DISABLED, then the user needs to install an update. So, call GooglePlayServicesUtil.getErrorDialog() and pass it the result error code. This returns a Dialog you should show, which provides an appropriate message about the error and provides an action that takes the user to Google Play Store to install the update.

    Radius Networks shares some sample code on their page. I would suggest looking at both the Google Play services geofence sample code and the Radius Networks Proximity Kit Android Reference App for two different ideas of how to handle this. Since checking for Google Play services will likely require your app to interact with the user in the event that Google Play services is not installed on the device, or is an incompatible version, this section of the integration is largely up to you the app developer.

  • Lastly, you need to enable geofences in Proximity Kit

Check out the Radius Networks sample app for further details on enabling geofences and implementing the geofence notifier.

To answer your direct question about sending an alert you can send it in the notifier callback:

public void didEnterGeofence(ProximityKitGeofenceRegion region) {
    NotificationCompat.Builder builder =
            new NotificationCompat.Builder(this)
                    .setContentTitle("Proximity Kit Reference Application")
                    .setContentText("A geofence is nearby.")
                    .setSmallIcon(R.drawable.ic_launcher);

    NotificationManager notificationManager =
            (NotificationManager) this.getSystemService(
                    Context.NOTIFICATION_SERVICE
            );
    notificationManager.notify(1, builder.build());
}
Comments