Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.sellger.konta.sketch_loyaltyapp.service;
- import android.app.Service;
- import android.content.Intent;
- import android.os.IBinder;
- import com.google.android.gms.common.api.GoogleApiClient;
- import com.google.android.gms.location.LocationRequest;
- import com.google.android.gms.location.LocationServices;
- public class LocationService extends Service {
- private static final String TAG = LocationService.class.getSimpleName();
- protected GoogleApiClient mGoogleApiClient;
- protected LocationRequest mLocationRequest;
- @Override
- public IBinder onBind(Intent intent) {
- return null;
- }
- @Override
- public void onCreate() {
- super.onCreate();
- setUpGoogleApiClient();
- }
- private void setUpGoogleApiClient() {
- mGoogleApiClient = new GoogleApiClient.Builder(this)
- .addApi(LocationServices.API)
- .build();
- mGoogleApiClient.connect();
- createLocationRequest();
- }
- private void createLocationRequest() {
- mLocationRequest = new LocationRequest();
- mLocationRequest.setInterval(30 * 1000);
- mLocationRequest.setFastestInterval(10 * 1000);
- mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement