Back to project page AndroidWearable-Samples.
The source code is released under:
Apache License
If you think the Android project AndroidWearable-Samples listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.example.android.wearable.geofencing; /* w w w . j av a 2 s. c om*/ import com.google.android.gms.location.Geofence; /** * A single Geofence object, defined by its center and radius. */ public class SimpleGeofence { // Instance variables private final String mId; private final double mLatitude; private final double mLongitude; private final float mRadius; private long mExpirationDuration; private int mTransitionType; /** * @param geofenceId The Geofence's request ID. * @param latitude Latitude of the Geofence's center in degrees. * @param longitude Longitude of the Geofence's center in degrees. * @param radius Radius of the geofence circle in meters. * @param expiration Geofence expiration duration. * @param transition Type of Geofence transition. */ public SimpleGeofence(String geofenceId, double latitude, double longitude, float radius, long expiration, int transition) { // Set the instance fields from the constructor. this.mId = geofenceId; this.mLatitude = latitude; this.mLongitude = longitude; this.mRadius = radius; this.mExpirationDuration = expiration; this.mTransitionType = transition; } // Instance field getters. public String getId() { return mId; } public double getLatitude() { return mLatitude; } public double getLongitude() { return mLongitude; } public float getRadius() { return mRadius; } public long getExpirationDuration() { return mExpirationDuration; } public int getTransitionType() { return mTransitionType; } /** * Creates a Location Services Geofence object from a SimpleGeofence. * @return A Geofence object. */ public Geofence toGeofence() { // Build a new Geofence object. return new Geofence.Builder() .setRequestId(mId) .setTransitionTypes(mTransitionType) .setCircularRegion(mLatitude, mLongitude, mRadius) .setExpirationDuration(mExpirationDuration) .build(); } }