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


Java LocationRequest.setFastestInterval方法代码示例

本文整理汇总了Java中com.google.android.gms.location.LocationRequest.setFastestInterval方法的典型用法代码示例。如果您正苦于以下问题:Java LocationRequest.setFastestInterval方法的具体用法?Java LocationRequest.setFastestInterval怎么用?Java LocationRequest.setFastestInterval使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.location.LocationRequest的用法示例。


在下文中一共展示了LocationRequest.setFastestInterval方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onConnected

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
@Override
    public void onConnected(@Nullable Bundle bundle) {
        Log.d(TAG, "Google API client connected");
//        String locationProvider = LocationManager.GPS_PROVIDER;
        mLocationRequest = new LocationRequest();
        mLocationRequest.setInterval(5000);
        mLocationRequest.setFastestInterval(500);
        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);


        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            // We should have permission as we ask for it at startup.
        } else {
            LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
        }
    }
 
开发者ID:jpmeijers,项目名称:ttnmapper_android_v2,代码行数:17,代码来源:TTNMapperService.java

示例2: requestLocationUpdates

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
@Override
public void requestLocationUpdates() {
  LocationRequest request = LocationRequest.create();

  if (interval != null) {
    request.setInterval(interval);
  }
  if (fastestInterval != null) {
    request.setFastestInterval(fastestInterval);
  }
  if (smallestDisplacement != null) {
    request.setSmallestDisplacement(smallestDisplacement);
  }

  updateRequestPriority(request);

  if (googleApiClient.isConnected()) {
    //noinspection MissingPermission
    LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, this);
  }
}
 
开发者ID:mapbox,项目名称:mapbox-events-android,代码行数:22,代码来源:GoogleLocationEngine.java

示例3: onConnected

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
@Override
public void onConnected(@Nullable Bundle bundle) {
    long interval = 100L;
    long fastInterval = interval / 2;
    LocationRequest mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(interval);
    mLocationRequest.setFastestInterval(fastInterval);

    if (Geolocation.LEVEL_EXACT.equals(this.level))
        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    else if (Geolocation.LEVEL_BUILDING.equals(this.level))
        mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
    else
        mLocationRequest.setPriority(LocationRequest.PRIORITY_LOW_POWER);
    LocationServices.FusedLocationApi.requestLocationUpdates(this.mGoogleApiClient, mLocationRequest, this);
}
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:17,代码来源:GoogleCurrentLocationProvider.java

示例4: onConnected

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
@Override
public void onConnected(Bundle bundle) {
    Toast.makeText(this, "onConnected", Toast.LENGTH_SHORT).show();

    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(1000);
    mLocationRequest.setFastestInterval(1000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);

    //mLocationRequest.setSmallestDisplacement(0.1F);

    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        return;
    }
    LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
}
 
开发者ID:CMPUT301W17T08,项目名称:Moodr,代码行数:24,代码来源:MapsActivity.java

示例5: onConnected

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
@Override
public void onConnected(Bundle bundle) {
    LocationRequest locationRequest = new LocationRequest();
    locationRequest.setInterval(1500);
    locationRequest.setFastestInterval(1500);
    locationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.ACCESS_FINE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
        LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, locationRequest, this);
    }
    getLocation();

    // Display # of spawn points loaded.
    // Make sure we have a location first.
    // If we run loadSpawnPoints before Google Play Services finds the location, we get a crash.
    if (mLastLocation != null) {
        loadSpawnPoints();
    }
    else {
        Toast.makeText(MapsActivity.this,
                "Location could not be detected, no spawn points loaded (try reloading from menu)",
                Toast.LENGTH_LONG).show();
    }
    mPolygonPointsGreen = Circles.loadAllPolygons(MapsActivity.this, mMap, mMarkerTransparency);
}
 
开发者ID:kav0rka,项目名称:VennTracker,代码行数:27,代码来源:MapsActivity.java

示例6: createLocationRequest

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
/**
 * Sets up the location request. Android has two location request settings:
 * {@code ACCESS_COARSE_LOCATION} and {@code ACCESS_FINE_LOCATION}. These settings control
 * the accuracy of the current location. This sample uses ACCESS_FINE_LOCATION, as defined in
 * the AndroidManifest.xml.
 * <p/>
 * When the ACCESS_FINE_LOCATION setting is specified, combined with a fast update
 * interval (5 seconds), the Fused Location Provider API returns location updates that are
 * accurate to within a few feet.
 * <p/>
 * These settings are appropriate for mapping applications that show real-time location
 * updates.
 */
private void createLocationRequest() {
    mLocationRequest = new LocationRequest();

    // Sets the desired interval for active location updates. This interval is
    // inexact. You may not receive updates at all if no location sources are available, or
    // you may receive them slower than requested. You may also receive updates faster than
    // requested if other applications are requesting location at a faster interval.
    mLocationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS);

    // Sets the fastest rate for active location updates. This interval is exact, and your
    // application will never receive updates faster than this value.
    mLocationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS);

    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}
 
开发者ID:Augugrumi,项目名称:SpaceRace,代码行数:29,代码来源:MapActivity.java

示例7: startLocationUpdates

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
protected void startLocationUpdates() {
    LocationRequest mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(10000);
    mLocationRequest.setFastestInterval(5000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    LocationServices.FusedLocationApi.requestLocationUpdates(
        mGoogleApiClient, mLocationRequest, this);
}
 
开发者ID:micromasterandroid,项目名称:androidadvanced,代码行数:10,代码来源:MainActivity.java

示例8: onConnected

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
@Override
public void onConnected(@Nullable Bundle bundle) {
    LocationRequest mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(1000);
    mLocationRequest.setFastestInterval(1000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
    if (ContextCompat.checkSelfPermission(this,
            android.Manifest.permission.ACCESS_FINE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
        LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
    }

}
 
开发者ID:PandhuWibowo,项目名称:HackJakRawan,代码行数:14,代码来源:MapsActivity.java

示例9: processQueue

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
private void processQueue() {
    if(ContextCompat.checkSelfPermission(queue.getFirst().getContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED && locationClient != null) {
        LocationRequest googleRequest = new LocationRequest();
        googleRequest.setInterval(2500);
        googleRequest.setFastestInterval(2500);
        googleRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

        locationClient.requestLocationUpdates(googleRequest, updateCallback, null);
    } else {
        for(LocationUtilRequest request : queue) {
            request.onLocationReceived(null, false);
            queue.remove(request);
        }
    }
}
 
开发者ID:jpelgrom,项目名称:Movie-Notifier-Android,代码行数:16,代码来源:LocationUtil.java

示例10: getLocationRequest

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
@NonNull private LocationRequest getLocationRequest() {
  LocationRequest locationRequest = new LocationRequest();
  locationRequest.setInterval(LOCATION_UPDATE_INTERVAL);
  locationRequest.setFastestInterval(LOCATION_UPDATE_FASTEST_INTERVAL);
  locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
  return locationRequest;
}
 
开发者ID:Arjun-sna,项目名称:LocationAware,代码行数:8,代码来源:LocationProvider.java

示例11: onConnected

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
@Override
public void onConnected(@Nullable Bundle bundle) {
    locationRequest = new LocationRequest();

    locationRequest.setInterval(1000);
    locationRequest.setFastestInterval(1000);
    locationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);

    if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) ==
            PackageManager.PERMISSION_GRANTED) {
        LocationServices.FusedLocationApi.requestLocationUpdates(client, locationRequest, this);
    }

}
 
开发者ID:CMPUT301F17T23,项目名称:routineKeen,代码行数:15,代码来源:MapsActivity.java

示例12: onConnected

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
@Override
public void onConnected(@Nullable Bundle bundle) {

    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(100);
    mLocationRequest.setFastestInterval(100);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    if (ContextCompat.checkSelfPermission(this,
            android.Manifest.permission.ACCESS_FINE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
        LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
    }
}
 
开发者ID:GeekyShiva,项目名称:Self-Driving-Car,代码行数:14,代码来源:MapsActivity.java

示例13: getLocationRequest

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
/**
 * Sets up the location request.
 *
 * @return The LocationRequest object containing the desired parameters.
 */
private LocationRequest getLocationRequest() {
    LocationRequest locationRequest = new LocationRequest();
    locationRequest.setInterval(10000);
    locationRequest.setFastestInterval(5000);
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    return locationRequest;
}
 
开发者ID:ngamolsky,项目名称:WalkMyAndroid-Location,代码行数:13,代码来源:MainActivity.java

示例14: buildLR

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
private LocationRequest buildLR() {
    LocationRequest request = new LocationRequest();
    request.setPriority(mLocationPriority);
    request.setInterval(mLocationInterval);
    request.setFastestInterval(mLocationFastestInterval);
    request.setSmallestDisplacement(mSmallestDisplacement);
    return request;
}
 
开发者ID:MustansirZia,项目名称:react-native-fused-location,代码行数:9,代码来源:FusedLocationModule.java

示例15: onConnected

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
@Override
public void onConnected(Bundle bundle) {
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(1000);
    mLocationRequest.setFastestInterval(1000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.ACCESS_FINE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
        LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
    }
}
 
开发者ID:ayushghd,项目名称:iSPY,代码行数:13,代码来源:MapsActivity3.java


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