當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。