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


Java LocationRequest.setInterval方法代码示例

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


在下文中一共展示了LocationRequest.setInterval方法的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: 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

示例3: createLocationRequest

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
/**
 * Sets up the location request.
 */
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:Francescopaolo44,项目名称:MedicalMe,代码行数:23,代码来源:MapsActivity.java

示例4: 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

示例5: onConnected

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
@Override
public void onConnected(@Nullable Bundle bundle) {
    //TODO: ask for permission at appropriate time
    LocationRequest locationRequest = new LocationRequest();
    locationRequest.setInterval(30000);
    locationRequest.setFastestInterval(30000);
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    if (Nammu.checkPermission(Manifest.permission.ACCESS_FINE_LOCATION)) {
        LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, locationRequest, LocationService.this);
    }
}
 
开发者ID:KwalaGroup,项目名称:Android-Client,代码行数:13,代码来源:LocationService.java

示例6: createLocationRequest

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
protected void createLocationRequest() {
    // create the location request and set parameters
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(10000);  // preferred update rate
    mLocationRequest.setFastestInterval(5000);  // fastest rate app can handle updates
    mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
}
 
开发者ID:MTBehnke,项目名称:NightSkyGuide,代码行数:8,代码来源:SettingsActivity.java

示例7: createLocationRequest

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
/**
 * Creating location request object
 */
private void createLocationRequest() {
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(UPDATE_INTERVAL);
    mLocationRequest.setFastestInterval(FATEST_INTERVAL);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    mLocationRequest.setSmallestDisplacement(DISPLACEMENT);
}
 
开发者ID:SoftprodigyIndia,项目名称:AndroidAppBoilerplate,代码行数:11,代码来源:LocationTracker.java

示例8: setUpComponents

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

    _googleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .build();
}
 
开发者ID:LenaShervarly,项目名称:TreasureHunting,代码行数:13,代码来源:LocationService.java

示例9: onCreate

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Retrieve location and camera position from saved instance state.
    if (savedInstanceState != null) {
        mLastKnownLocation = savedInstanceState.getParcelable(KEY_LOCATION);
    }
    locationInfoList = new ArrayList<LocationInfo>();
    setContentView(R.layout.activity_main);
    //helper = new MyDBHelper(this, "expense.db", null, 1);

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */,
                    this /* OnConnectionFailedListener */)
            .addApi(LocationServices.API)
            .addApi(Places.GEO_DATA_API)
            .addApi(Places.PLACE_DETECTION_API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
    mGoogleApiClient.connect();
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(10*1000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    mLocationRequest.setFastestInterval(1000);


}
 
开发者ID:jorseph,项目名称:SearchRestaurant,代码行数:29,代码来源:MainActivity.java

示例10: createLocationRequest

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
private LocationRequest createLocationRequest() {
    LocationRequest locationRequest = new LocationRequest();
    locationRequest.setInterval(LOCATION_INTERVAL);
    locationRequest.setFastestInterval(LOCATION_INTERVAL);
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    return locationRequest;
}
 
开发者ID:ANFR-France,项目名称:proto-collecte,代码行数:8,代码来源:ParcoursService.java

示例11: findCoords

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
private void findCoords() {
    LocationRequest request = LocationRequest.create();
    request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    request.setNumUpdates(1);
    request.setInterval(0);

    LocationServices.FusedLocationApi
            .requestLocationUpdates(mClient, request, new LocationListener() {
                @Override
                public void onLocationChanged(Location location) {
                    double lat = location.getLatitude();
                    double lon = location.getLongitude();
                    mLocation.setLatitude(lat);
                    mLocation.setLongitude(lon);
                    mWasLocationFixed = true;
                    
                    //Sort the order in which places are shown
                    //depending on how far they are from us (= by distance ascending)
                    Collections.sort(mPlaces, new Comparator<Visitable>() {
                        @Override
                        public int compare(Visitable a, Visitable b) {
                            Location aLoc = a.getLocation();
                            Location bLoc = b.getLocation();
                            return (int) aLoc.distanceTo(mLocation) - (int) bLoc.distanceTo(mLocation);
                        }
                    });
                    mAdapter.setPlaces(mPlaces);
                    mAdapter.notifyDataSetChanged();
                }
            });
}
 
开发者ID:plweegie,项目名称:piast-trail,代码行数:32,代码来源:PlaceListFragment.java

示例12: onConnected

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
@Override
public void onConnected(@Nullable Bundle bundle) {
    LocationRequest locationRequest = new LocationRequest();
    locationRequest.setInterval(REQUEST_INTERVAL);
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
        // Request location updates from the Google API client
        LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
    }
}
 
开发者ID:thandomy,项目名称:foodie,代码行数:11,代码来源:HomeActivity.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: findImage

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
private void findImage() {
    LocationRequest request = LocationRequest.create();
    request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    request.setNumUpdates(1);
    request.setInterval(0);
    LocationServices.FusedLocationApi
            .requestLocationUpdates(mClient, request, new LocationListener() {
                @Override
                public void onLocationChanged(Location location) {
                    Log.i(TAG, "Got a fix: " + location);
                    new SearchTask().execute(location);
                }
            });
}
 
开发者ID:rsippl,项目名称:AndroidProgramming3e,代码行数:15,代码来源:LocatrFragment.java

示例15: createLocationRequest

import com.google.android.gms.location.LocationRequest; //导入方法依赖的package包/类
private LocationRequest createLocationRequest() {
    LocationRequest locationRequest = new LocationRequest();
    locationRequest.setInterval(LOCATION_REFRESH_INTERVAL);
    locationRequest.setFastestInterval(LOCATION_REFRESH_INTERVAL / 2);
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    return locationRequest;
}
 
开发者ID:ANFR-France,项目名称:proto-collecte,代码行数:8,代码来源:MainActivity.java


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