本文整理汇总了Java中com.google.android.gms.location.GeofencingRequest.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java GeofencingRequest.Builder方法的具体用法?Java GeofencingRequest.Builder怎么用?Java GeofencingRequest.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.location.GeofencingRequest
的用法示例。
在下文中一共展示了GeofencingRequest.Builder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGeofencingRequest
import com.google.android.gms.location.GeofencingRequest; //导入方法依赖的package包/类
private GeofencingRequest getGeofencingRequest() {
if (this.place == null || this.place.getLocation() == null) {
return null;
}
// called when the transition associated with the Geofence is triggered)
List<Geofence> geoFenceList = new ArrayList<Geofence>();
geoFenceList.add(new Geofence.Builder()
.setRequestId(GEOFENCE_REQUEST_ID)
.setCircularRegion(this.place.getLocation().getLatitude(),
this.place.getLocation().getLongitude(),
GEOFENCE_RADIUS_IN_METERS
)
.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_DWELL | Geofence.GEOFENCE_TRANSITION_ENTER)
.setLoiteringDelay(LOITERING_DELAY_MS)
.setNotificationResponsiveness(NOTIFICATION_RESPONSIVENESS_MS)
.setExpirationDuration(Geofence.NEVER_EXPIRE)
.build());
GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER | GeofencingRequest.INITIAL_TRIGGER_DWELL);
builder.addGeofences(geoFenceList);
return builder.build();
}
示例2: location_geofencesCreateTriggerRequest
import com.google.android.gms.location.GeofencingRequest; //导入方法依赖的package包/类
/**
* Creates a geofencing trigger request. This will make the location service
* to launch geofencing events (enter/exit events) with the specified
* geofence list.
* <br>
* See Geofences at <a href="http://developer.android.com/intl/es/training/location/geofencing.html">Google developer</a>.
* <br><br>
* Note:<br><br>
*
* Requires the permission {@link android.permission.ACCESS_FINE_LOCATION}.
*
* @param geofenceList The list of Geofences to watch.
*/
public static GeofencingRequest location_geofencesCreateTriggerRequest(List<Geofence> geofenceList) {
GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
//The GEOFENCE_TRANSITION_ENTER/GEOFENCE_TRANSITION_EXIT transition
//triggers when a device enters/exits a geofence.
//
//Specifying INITIAL_TRIGGER_ENTER tells Location services that
//GEOFENCE_TRANSITION_ENTER should be triggered if the the device is
//already inside the geofence.
//
//In many cases, it may be preferable to use instead INITIAL_TRIGGER_DWELL,
//which triggers events only when the user stops for a defined duration
//within a geofence.
builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER);
builder.addGeofences(geofenceList);
return builder.build();
}
示例3: getGeofenceRequest
import com.google.android.gms.location.GeofencingRequest; //导入方法依赖的package包/类
/***
* creates a {@link GeofencingRequest} request object using the mGeofenceList , Arraylist of geofences.
* Used by {@link #registerAllGeofences()}
*
* @return the GeofencingRequest object.
*/
private GeofencingRequest getGeofenceRequest(){
GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER);
builder.addGeofences(mGeofenceList);
return builder.build();
}
示例4: getGeofencingRequest
import com.google.android.gms.location.GeofencingRequest; //导入方法依赖的package包/类
private static GeofencingRequest getGeofencingRequest(List<Place> places) {
GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER | GeofencingRequest.INITIAL_TRIGGER_DWELL);
//builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_DWELL);
builder.addGeofences(getGeofenceList(places));
return builder.build();
}
示例5: getGeofencingRequest
import com.google.android.gms.location.GeofencingRequest; //导入方法依赖的package包/类
/**
* Builds and returns a GeofencingRequest. Specifies the list of geofences to be monitored.
* Also specifies how the geofence notifications are initially triggered.
*/
private GeofencingRequest getGeofencingRequest() {
GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
// The INITIAL_TRIGGER_ENTER flag indicates that geofencing service should trigger a
// GEOFENCE_TRANSITION_ENTER notification when the geofence is added and if the device
// is already inside that geofence.
builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER);
// Add the geofences to be monitored by geofencing service.
builder.addGeofences(mGeofenceList);
// Return a GeofencingRequest.
return builder.build();
}
示例6: getGeofencingRequest
import com.google.android.gms.location.GeofencingRequest; //导入方法依赖的package包/类
/**
* Create Geofencing request
*
* @return GeofencingRequest initialised with a list of Geofences
*/
private GeofencingRequest getGeofencingRequest() {
GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
// if just added and if inside the geofence
builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER);
builder.addGeofences(mGeofenceList);
return builder.build();
}
示例7: getGeoFencingRequest
import com.google.android.gms.location.GeofencingRequest; //导入方法依赖的package包/类
private GeofencingRequest getGeoFencingRequest()
{
GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER);
builder.addGeofences(mGeofenceList);
return builder.build();
}
示例8: addGeofence
import com.google.android.gms.location.GeofencingRequest; //导入方法依赖的package包/类
/**
* Add a geofence to the store
* This will also add the geofence to the google api client if connected. If not, it will trigger a connection
* This call requires that the permission ACCESS_FINE_LOCATION is granted
* @param storableGeofence the geofence to store
* @return true if add has been asked, false otherwise. false could be returned if the geofence is expired
*/
@RequiresPermission("android.permission.ACCESS_FINE_LOCATION")
public boolean addGeofence(@NonNull StorableGeofence storableGeofence) {
boolean addedOngoing = false;
if (ActivityCompat.checkSelfPermission(mContext,
Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
if (!storableGeofence.isExpired()) {
mToAddStore.storeGeofence(storableGeofence);
if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
GeofenceAddStatus addStatus = new GeofenceAddStatus(storableGeofence);
GeofencingRequest.Builder requestBuilder = new GeofencingRequest.Builder();
requestBuilder.addGeofence(storableGeofence.toGeofence());
mGeofencingAPI.addGeofences(mGoogleApiClient, requestBuilder.build(),
createRequestPendingIntent(storableGeofence)).setResultCallback(addStatus);
Log.i(TAG, "Added " + storableGeofence);
} else {
googleApiConnect();
}
addedOngoing = true;
}
} else {
Log.e(TAG, "Could not add the geofence: permission ACCESS_FINE_LOCATION required");
}
return addedOngoing;
}
示例9: getGeofencingRequest
import com.google.android.gms.location.GeofencingRequest; //导入方法依赖的package包/类
private static GeofencingRequest getGeofencingRequest(List<Geofence> geofenceList) {
GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
// The INITIAL_TRIGGER_ENTER flag indicates that geofencing service should trigger a
// GEOFENCE_TRANSITION_ENTER notification when the geofence is added and if the device
// is already inside that geofence.
builder.setInitialTrigger(0);
builder.addGeofences(geofenceList);
return builder.build();
}
示例10: addGeofences
import com.google.android.gms.location.GeofencingRequest; //导入方法依赖的package包/类
@WorkerThread
public void addGeofences(List<Geofence> geofenceList) {
Log.d(); if (!isConnected()) return;
if (geofenceList.isEmpty()) {
Log.d("List of geofences is empty: do nothing");
return;
}
GeofencingRequest.Builder requestBuilder = new GeofencingRequest.Builder();
requestBuilder.addGeofences(geofenceList);
LocationServices.GeofencingApi.addGeofences(mGoogleApiClient, requestBuilder.build(), getPendingIntent()).await();
Log.d(geofenceList.size() + " geofences added");
}
示例11: addGeofences
import com.google.android.gms.location.GeofencingRequest; //导入方法依赖的package包/类
public PendingResult<Status> addGeofences(@NonNull Collection<GeoAlarm> alarms) {
GeofencingRequest.Builder geofenceRequestBuilder = new GeofencingRequest.Builder();
geofenceRequestBuilder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER);
for (GeoAlarm alarm : alarms) {
geofenceRequestBuilder.addGeofence(getGeofence(alarm));
}
return LocationServices.GeofencingApi.addGeofences(apiClient, geofenceRequestBuilder.build(), pendingIntent);
}
示例12: createGeofenceRequest
import com.google.android.gms.location.GeofencingRequest; //导入方法依赖的package包/类
@NonNull
private GeofencingRequest createGeofenceRequest(Location location) {
List<Geofence> fences = new ArrayList<>();
// TODO: for multiple home support different requestIds for different homes have to be used!
if (enterRadius == exitRadius) {
fences.add(new Geofence.Builder()
.setRequestId(GEO_BOTH_LISTENER_KEY)
.setCircularRegion(
location.getLatitude(),
location.getLongitude(),
(float)enterRadius
)
.setExpirationDuration(Geofence.NEVER_EXPIRE)
.setLoiteringDelay(20 * 1000)
.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT)
.build()
);
} else {
fences.add(new Geofence.Builder()
.setRequestId(GEO_ENTER_LISTENER_KEY)
.setCircularRegion(
location.getLatitude(),
location.getLongitude(),
(float)enterRadius
)
.setExpirationDuration(Geofence.NEVER_EXPIRE)
.setLoiteringDelay(20 * 1000)
.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER)
.build()
);
fences.add(new Geofence.Builder()
.setRequestId(GEO_EXIT_LISTENER_KEY)
.setCircularRegion(
location.getLatitude(),
location.getLongitude(),
(float)exitRadius
)
.setExpirationDuration(Geofence.NEVER_EXPIRE)
.setLoiteringDelay(20 * 1000)
.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_EXIT)
.build()
);
}
GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
// we do not use ANY initial trigger, because this causes the strange behavior that the app
// could deactivate the secure/alarm mode automatically when the app is launched, due to
// the reason that the user is currently at home. This should not happen because of:
// a) The user should be able to use the security system while he is sleeping in the bed room
// b) DEMO show cases
// Also, this worked only reliable for ENTER.
int init = 0; // set ZERO because ENTER is the default!
if (initTrigger)
init = GeofencingRequest.INITIAL_TRIGGER_ENTER | GeofencingRequest.INITIAL_TRIGGER_EXIT;
builder.setInitialTrigger(init);
builder.addGeofences(fences);
return builder.build();
}
示例13: getGeofencingRequest
import com.google.android.gms.location.GeofencingRequest; //导入方法依赖的package包/类
private GeofencingRequest getGeofencingRequest() {
GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
builder.setInitialTrigger(Geofence.GEOFENCE_TRANSITION_ENTER);
builder.addGeofences(geofences);
return builder.build();
}
示例14: geofencingRequest
import com.google.android.gms.location.GeofencingRequest; //导入方法依赖的package包/类
private GeofencingRequest geofencingRequest() {
GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER);
builder.addGeofences(geofences);
return builder.build();
}
示例15: getGeofencingRequest
import com.google.android.gms.location.GeofencingRequest; //导入方法依赖的package包/类
private static GeofencingRequest getGeofencingRequest(Geofence geofence) {
GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER);
builder.addGeofence(geofence);
return builder.build();
}