简体   繁体   中英

Geofencing in android app

I am building a check in and check out application currently. User should be able to check in with the current location and when he goes 50 meters away from the current location he should be checked out.

Can this be implemented using Geo Fencing for android?

I came across this piece of code but do not know how to use:

SimpleGeofence mUIGeofence1 = new SimpleGeofence("1",
               Double.valueOf(mLatitude1.getText().toString()),
               Double.valueOf(mLongitude1.getText().toString()),
               Float.valueOf(mRadius1.getText().toString()),
               GEOFENCE_EXPIRATION_TIME,
               // This geofence records only entry transitions
               Geofence.GEOFENCE_TRANSITION_ENTER);
mGeofenceStorage.setGeofence("1", mUIGeofence1);

I would really appreciate if the correct way to use geo fencing could be given.

You can implement this using geofencing.

The sample code you posted has to do with persisting a Geofence object.

If you want to know how to register a Geofence, check out this presentation on using the geofencing APIs and these android docs . The prezi has some sample code that boils down the use of the APIs to 10 lines of code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM