Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. package com.sellger.konta.sketch_loyaltyapp.service;
  2.  
  3. import android.app.Service;
  4. import android.content.Intent;
  5. import android.os.IBinder;
  6.  
  7. import com.google.android.gms.common.api.GoogleApiClient;
  8. import com.google.android.gms.location.LocationRequest;
  9. import com.google.android.gms.location.LocationServices;
  10.  
  11. public class LocationService extends Service {
  12.  
  13. private static final String TAG = LocationService.class.getSimpleName();
  14.  
  15. protected GoogleApiClient mGoogleApiClient;
  16. protected LocationRequest mLocationRequest;
  17.  
  18. @Override
  19. public IBinder onBind(Intent intent) {
  20. return null;
  21. }
  22.  
  23. @Override
  24. public void onCreate() {
  25. super.onCreate();
  26. setUpGoogleApiClient();
  27. }
  28.  
  29. private void setUpGoogleApiClient() {
  30. mGoogleApiClient = new GoogleApiClient.Builder(this)
  31. .addApi(LocationServices.API)
  32. .build();
  33. mGoogleApiClient.connect();
  34.  
  35. createLocationRequest();
  36. }
  37.  
  38. private void createLocationRequest() {
  39. mLocationRequest = new LocationRequest();
  40. mLocationRequest.setInterval(30 * 1000);
  41. mLocationRequest.setFastestInterval(10 * 1000);
  42. mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement