当前位置: 首页>>代码示例>>Java>>正文


Java GeofencingRequest.Builder方法代码示例

本文整理汇总了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();
}
 
开发者ID:hypertrack,项目名称:hypertrack-live-android,代码行数:25,代码来源:ActionManager.java

示例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();
}
 
开发者ID:javocsoft,项目名称:javocsoft-toolbox,代码行数:30,代码来源:ToolBox.java

示例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();
}
 
开发者ID:samagra14,项目名称:Shush,代码行数:13,代码来源:Geofencing.java

示例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();
}
 
开发者ID:abicelis,项目名称:Remindy,代码行数:8,代码来源:GeofenceUtil.java

示例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();
}
 
开发者ID:RobinCaroff,项目名称:MyGeofencer,代码行数:19,代码来源:GeofencingController.java

示例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();
}
 
开发者ID:dmytroKarataiev,项目名称:EarthquakeSurvival,代码行数:13,代码来源:PagerActivity.java

示例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();
}
 
开发者ID:j-mateo,项目名称:hack2help,代码行数:8,代码来源:TourPlaybackActivity.java

示例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;
}
 
开发者ID:djavan-bertrand,项目名称:GeofenceHelper,代码行数:38,代码来源:StorableGeofenceManager.java

示例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();
}
 
开发者ID:LocativeHQ,项目名称:Locative-Android,代码行数:10,代码来源:LocativeService.java

示例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");
}
 
开发者ID:BoD,项目名称:DoorCodeNotifier,代码行数:13,代码来源:GeofencingHelper.java

示例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);
}
 
开发者ID:maurizi,项目名称:Geoclock,代码行数:10,代码来源:LocationServiceGoogle.java

示例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();
}
 
开发者ID:bsautermeister,项目名称:GeoFencer,代码行数:64,代码来源:PlayGeofenceProvider.java

示例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();
}
 
开发者ID:rasmussaks,项目名称:aken-ajalukku,代码行数:7,代码来源:GeofenceManager.java

示例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();
}
 
开发者ID:infobip,项目名称:mobile-messaging-sdk-android,代码行数:7,代码来源:GeofencingImpl.java

示例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();
}
 
开发者ID:Power-Switch,项目名称:PowerSwitch_Android,代码行数:7,代码来源:GeofenceApiHandler.java


注:本文中的com.google.android.gms.location.GeofencingRequest.Builder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。