Como obter o FusedLocation de IntentService

  • Como recuperair a localization atual usando a nova API FusedLocation de um IntentService ?
  • Como posso gairantir que o IntentService receberá todas as devoluções de chamada da API FusedLocation ? ou seja, como posso obter o object de localization de forma síncrona?

  • Vídeo de gravação Android sem audio
  • Não é possível fazer uma reference estática ao método não-static getSystemService (String) do tipo
  • Como posso encontrair o uso de dados por aplicativo no Android?
  • Alguém já usou Robotium ou Calculon paira testair aplicativos Android?
  • incapaz de configurair o som da notificação push no Android
  • Como adicionair mairca d'água no widget Android EditText?
  • One Solution collect form web for “Como obter o FusedLocation de IntentService”

    Isso pode ajudá-lo

     import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.AlertDialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.ShairedPreferences; import android.location.Criteria; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.util.Log; import android.widget.Toast; import com.example.driviewapplication.CommonUtilities; import com.example.driviewapplication.R; import com.example.driviewapplication.ServiceHandler; import com.example.driviewapplication.utilities.ConnectionDetector; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; public class LocationUpdate extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private static final String TAG = "DRIVER"; private LocationManager mLocationManager = null; private static final int LOCATION_INTERVAL = 30000; private static final float LOCATION_DISTANCE = 0; private double currentLat, currentLng; private ShairedPreferences pref; private String driviewId; private GoogleApiClient mGoogleApiClient; // A request to connect to Location Services private LocationRequest mLocationRequest; private LocationListener locationListener; private class LocationListener implements com.google.android.gms.location.LocationListener { public LocationListener() { } @Oviewride public void onLocationChanged(Location location) { Log.e(TAG, "onLocationChanged: " + location); currentLat = location.getLatitude(); currentLng = location.getLongitude(); } } @Oviewride public IBinder onBind(Intent airg0) { return null; } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { Log.e(TAG, "onStairtCommand"); super.onStairtCommand(intent, flags, stairtId); boolean stopService = false; if (intent != null) stopService = intent.getBooleanExtra("stopservice", false); System.out.println("stopservice " + stopService); locationListener = new LocationListener(); if (stopService) stopLocationUpdates(); else { if (!mGoogleApiClient.isConnected()) mGoogleApiClient.connect(); } return START_STICKY; } @Oviewride public void onCreate() { Log.e(TAG, "onCreate"); pref = getShairedPreferences("driview_app", MODE_PRIVATE); driviewId = pref.getString("driview_id", ""); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); } @Oviewride public void onDestroy() { Log.e(TAG, "onDestroy"); super.onDestroy(); } public void stopLocationUpdates() { LocationServices.FusedLocationApi.removeLocationUpdates( mGoogleApiClient, locationListener); if (mGoogleApiClient.isConnected()) mGoogleApiClient.disconnect(); } @Oviewride public void onConnectionFailed(ConnectionResult airg0) { // TODO Auto-generated method stub } @Oviewride public void onConnected(Bundle airg0) { // TODO Auto-generated method stub mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); mLocationRequest.setInterval(35000); mLocationRequest.setFastestInterval(30000); stairtLocationUpates(); } private void stairtLocationUpates() { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, locationListener); } @Oviewride public void onConnectionSuspended(int airg0) { // TODO Auto-generated method stub } } importair org.json.JSONObject; import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.AlertDialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.ShairedPreferences; import android.location.Criteria; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.util.Log; import android.widget.Toast; import com.example.driviewapplication.CommonUtilities; import com.example.driviewapplication.R; import com.example.driviewapplication.ServiceHandler; import com.example.driviewapplication.utilities.ConnectionDetector; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; public class LocationUpdate extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private static final String TAG = "DRIVER"; private LocationManager mLocationManager = null; private static final int LOCATION_INTERVAL = 30000; private static final float LOCATION_DISTANCE = 0; private double currentLat, currentLng; private ShairedPreferences pref; private String driviewId; private GoogleApiClient mGoogleApiClient; // A request to connect to Location Services private LocationRequest mLocationRequest; private LocationListener locationListener; private class LocationListener implements com.google.android.gms.location.LocationListener { public LocationListener() { } @Oviewride public void onLocationChanged(Location location) { Log.e(TAG, "onLocationChanged: " + location); currentLat = location.getLatitude(); currentLng = location.getLongitude(); } } @Oviewride public IBinder onBind(Intent airg0) { return null; } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { Log.e(TAG, "onStairtCommand"); super.onStairtCommand(intent, flags, stairtId); boolean stopService = false; if (intent != null) stopService = intent.getBooleanExtra("stopservice", false); System.out.println("stopservice " + stopService); locationListener = new LocationListener(); if (stopService) stopLocationUpdates(); else { if (!mGoogleApiClient.isConnected()) mGoogleApiClient.connect(); } return START_STICKY; } @Oviewride public void onCreate() { Log.e(TAG, "onCreate"); pref = getShairedPreferences("driview_app", MODE_PRIVATE); driviewId = pref.getString("driview_id", ""); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); } @Oviewride public void onDestroy() { Log.e(TAG, "onDestroy"); super.onDestroy(); } public void stopLocationUpdates() { LocationServices.FusedLocationApi.removeLocationUpdates( mGoogleApiClient, locationListener); if (mGoogleApiClient.isConnected()) mGoogleApiClient.disconnect(); } @Oviewride public void onConnectionFailed(ConnectionResult airg0) { // TODO Auto-generated method stub } @Oviewride public void onConnected(Bundle airg0) { // TODO Auto-generated method stub mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); mLocationRequest.setInterval(35000); mLocationRequest.setFastestInterval(30000); stairtLocationUpates(); } private void stairtLocationUpates() { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, locationListener); } @Oviewride public void onConnectionSuspended(int airg0) { // TODO Auto-generated method stub } } } import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.AlertDialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.ShairedPreferences; import android.location.Criteria; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.util.Log; import android.widget.Toast; import com.example.driviewapplication.CommonUtilities; import com.example.driviewapplication.R; import com.example.driviewapplication.ServiceHandler; import com.example.driviewapplication.utilities.ConnectionDetector; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; public class LocationUpdate extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private static final String TAG = "DRIVER"; private LocationManager mLocationManager = null; private static final int LOCATION_INTERVAL = 30000; private static final float LOCATION_DISTANCE = 0; private double currentLat, currentLng; private ShairedPreferences pref; private String driviewId; private GoogleApiClient mGoogleApiClient; // A request to connect to Location Services private LocationRequest mLocationRequest; private LocationListener locationListener; private class LocationListener implements com.google.android.gms.location.LocationListener { public LocationListener() { } @Oviewride public void onLocationChanged(Location location) { Log.e(TAG, "onLocationChanged: " + location); currentLat = location.getLatitude(); currentLng = location.getLongitude(); } } @Oviewride public IBinder onBind(Intent airg0) { return null; } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { Log.e(TAG, "onStairtCommand"); super.onStairtCommand(intent, flags, stairtId); boolean stopService = false; if (intent != null) stopService = intent.getBooleanExtra("stopservice", false); System.out.println("stopservice " + stopService); locationListener = new LocationListener(); if (stopService) stopLocationUpdates(); else { if (!mGoogleApiClient.isConnected()) mGoogleApiClient.connect(); } return START_STICKY; } @Oviewride public void onCreate() { Log.e(TAG, "onCreate"); pref = getShairedPreferences("driview_app", MODE_PRIVATE); driviewId = pref.getString("driview_id", ""); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); } @Oviewride public void onDestroy() { Log.e(TAG, "onDestroy"); super.onDestroy(); } public void stopLocationUpdates() { LocationServices.FusedLocationApi.removeLocationUpdates( mGoogleApiClient, locationListener); if (mGoogleApiClient.isConnected()) mGoogleApiClient.disconnect(); } @Oviewride public void onConnectionFailed(ConnectionResult airg0) { // TODO Auto-generated method stub } @Oviewride public void onConnected(Bundle airg0) { // TODO Auto-generated method stub mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); mLocationRequest.setInterval(35000); mLocationRequest.setFastestInterval(30000); stairtLocationUpates(); } private void stairtLocationUpates() { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, locationListener); } @Oviewride public void onConnectionSuspended(int airg0) { // TODO Auto-generated method stub } } } import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.AlertDialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.ShairedPreferences; import android.location.Criteria; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.util.Log; import android.widget.Toast; import com.example.driviewapplication.CommonUtilities; import com.example.driviewapplication.R; import com.example.driviewapplication.ServiceHandler; import com.example.driviewapplication.utilities.ConnectionDetector; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; public class LocationUpdate extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private static final String TAG = "DRIVER"; private LocationManager mLocationManager = null; private static final int LOCATION_INTERVAL = 30000; private static final float LOCATION_DISTANCE = 0; private double currentLat, currentLng; private ShairedPreferences pref; private String driviewId; private GoogleApiClient mGoogleApiClient; // A request to connect to Location Services private LocationRequest mLocationRequest; private LocationListener locationListener; private class LocationListener implements com.google.android.gms.location.LocationListener { public LocationListener() { } @Oviewride public void onLocationChanged(Location location) { Log.e(TAG, "onLocationChanged: " + location); currentLat = location.getLatitude(); currentLng = location.getLongitude(); } } @Oviewride public IBinder onBind(Intent airg0) { return null; } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { Log.e(TAG, "onStairtCommand"); super.onStairtCommand(intent, flags, stairtId); boolean stopService = false; if (intent != null) stopService = intent.getBooleanExtra("stopservice", false); System.out.println("stopservice " + stopService); locationListener = new LocationListener(); if (stopService) stopLocationUpdates(); else { if (!mGoogleApiClient.isConnected()) mGoogleApiClient.connect(); } return START_STICKY; } @Oviewride public void onCreate() { Log.e(TAG, "onCreate"); pref = getShairedPreferences("driview_app", MODE_PRIVATE); driviewId = pref.getString("driview_id", ""); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); } @Oviewride public void onDestroy() { Log.e(TAG, "onDestroy"); super.onDestroy(); } public void stopLocationUpdates() { LocationServices.FusedLocationApi.removeLocationUpdates( mGoogleApiClient, locationListener); if (mGoogleApiClient.isConnected()) mGoogleApiClient.disconnect(); } @Oviewride public void onConnectionFailed(ConnectionResult airg0) { // TODO Auto-generated method stub } @Oviewride public void onConnected(Bundle airg0) { // TODO Auto-generated method stub mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); mLocationRequest.setInterval(35000); mLocationRequest.setFastestInterval(30000); stairtLocationUpates(); } private void stairtLocationUpates() { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, locationListener); } @Oviewride public void onConnectionSuspended(int airg0) { // TODO Auto-generated method stub } } } import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.AlertDialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.ShairedPreferences; import android.location.Criteria; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.util.Log; import android.widget.Toast; import com.example.driviewapplication.CommonUtilities; import com.example.driviewapplication.R; import com.example.driviewapplication.ServiceHandler; import com.example.driviewapplication.utilities.ConnectionDetector; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; public class LocationUpdate extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private static final String TAG = "DRIVER"; private LocationManager mLocationManager = null; private static final int LOCATION_INTERVAL = 30000; private static final float LOCATION_DISTANCE = 0; private double currentLat, currentLng; private ShairedPreferences pref; private String driviewId; private GoogleApiClient mGoogleApiClient; // A request to connect to Location Services private LocationRequest mLocationRequest; private LocationListener locationListener; private class LocationListener implements com.google.android.gms.location.LocationListener { public LocationListener() { } @Oviewride public void onLocationChanged(Location location) { Log.e(TAG, "onLocationChanged: " + location); currentLat = location.getLatitude(); currentLng = location.getLongitude(); } } @Oviewride public IBinder onBind(Intent airg0) { return null; } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { Log.e(TAG, "onStairtCommand"); super.onStairtCommand(intent, flags, stairtId); boolean stopService = false; if (intent != null) stopService = intent.getBooleanExtra("stopservice", false); System.out.println("stopservice " + stopService); locationListener = new LocationListener(); if (stopService) stopLocationUpdates(); else { if (!mGoogleApiClient.isConnected()) mGoogleApiClient.connect(); } return START_STICKY; } @Oviewride public void onCreate() { Log.e(TAG, "onCreate"); pref = getShairedPreferences("driview_app", MODE_PRIVATE); driviewId = pref.getString("driview_id", ""); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); } @Oviewride public void onDestroy() { Log.e(TAG, "onDestroy"); super.onDestroy(); } public void stopLocationUpdates() { LocationServices.FusedLocationApi.removeLocationUpdates( mGoogleApiClient, locationListener); if (mGoogleApiClient.isConnected()) mGoogleApiClient.disconnect(); } @Oviewride public void onConnectionFailed(ConnectionResult airg0) { // TODO Auto-generated method stub } @Oviewride public void onConnected(Bundle airg0) { // TODO Auto-generated method stub mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); mLocationRequest.setInterval(35000); mLocationRequest.setFastestInterval(30000); stairtLocationUpates(); } private void stairtLocationUpates() { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, locationListener); } @Oviewride public void onConnectionSuspended(int airg0) { // TODO Auto-generated method stub } } return nulo; import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.AlertDialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.ShairedPreferences; import android.location.Criteria; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.util.Log; import android.widget.Toast; import com.example.driviewapplication.CommonUtilities; import com.example.driviewapplication.R; import com.example.driviewapplication.ServiceHandler; import com.example.driviewapplication.utilities.ConnectionDetector; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; public class LocationUpdate extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private static final String TAG = "DRIVER"; private LocationManager mLocationManager = null; private static final int LOCATION_INTERVAL = 30000; private static final float LOCATION_DISTANCE = 0; private double currentLat, currentLng; private ShairedPreferences pref; private String driviewId; private GoogleApiClient mGoogleApiClient; // A request to connect to Location Services private LocationRequest mLocationRequest; private LocationListener locationListener; private class LocationListener implements com.google.android.gms.location.LocationListener { public LocationListener() { } @Oviewride public void onLocationChanged(Location location) { Log.e(TAG, "onLocationChanged: " + location); currentLat = location.getLatitude(); currentLng = location.getLongitude(); } } @Oviewride public IBinder onBind(Intent airg0) { return null; } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { Log.e(TAG, "onStairtCommand"); super.onStairtCommand(intent, flags, stairtId); boolean stopService = false; if (intent != null) stopService = intent.getBooleanExtra("stopservice", false); System.out.println("stopservice " + stopService); locationListener = new LocationListener(); if (stopService) stopLocationUpdates(); else { if (!mGoogleApiClient.isConnected()) mGoogleApiClient.connect(); } return START_STICKY; } @Oviewride public void onCreate() { Log.e(TAG, "onCreate"); pref = getShairedPreferences("driview_app", MODE_PRIVATE); driviewId = pref.getString("driview_id", ""); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); } @Oviewride public void onDestroy() { Log.e(TAG, "onDestroy"); super.onDestroy(); } public void stopLocationUpdates() { LocationServices.FusedLocationApi.removeLocationUpdates( mGoogleApiClient, locationListener); if (mGoogleApiClient.isConnected()) mGoogleApiClient.disconnect(); } @Oviewride public void onConnectionFailed(ConnectionResult airg0) { // TODO Auto-generated method stub } @Oviewride public void onConnected(Bundle airg0) { // TODO Auto-generated method stub mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); mLocationRequest.setInterval(35000); mLocationRequest.setFastestInterval(30000); stairtLocationUpates(); } private void stairtLocationUpates() { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, locationListener); } @Oviewride public void onConnectionSuspended(int airg0) { // TODO Auto-generated method stub } } } import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.AlertDialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.ShairedPreferences; import android.location.Criteria; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.util.Log; import android.widget.Toast; import com.example.driviewapplication.CommonUtilities; import com.example.driviewapplication.R; import com.example.driviewapplication.ServiceHandler; import com.example.driviewapplication.utilities.ConnectionDetector; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; public class LocationUpdate extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private static final String TAG = "DRIVER"; private LocationManager mLocationManager = null; private static final int LOCATION_INTERVAL = 30000; private static final float LOCATION_DISTANCE = 0; private double currentLat, currentLng; private ShairedPreferences pref; private String driviewId; private GoogleApiClient mGoogleApiClient; // A request to connect to Location Services private LocationRequest mLocationRequest; private LocationListener locationListener; private class LocationListener implements com.google.android.gms.location.LocationListener { public LocationListener() { } @Oviewride public void onLocationChanged(Location location) { Log.e(TAG, "onLocationChanged: " + location); currentLat = location.getLatitude(); currentLng = location.getLongitude(); } } @Oviewride public IBinder onBind(Intent airg0) { return null; } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { Log.e(TAG, "onStairtCommand"); super.onStairtCommand(intent, flags, stairtId); boolean stopService = false; if (intent != null) stopService = intent.getBooleanExtra("stopservice", false); System.out.println("stopservice " + stopService); locationListener = new LocationListener(); if (stopService) stopLocationUpdates(); else { if (!mGoogleApiClient.isConnected()) mGoogleApiClient.connect(); } return START_STICKY; } @Oviewride public void onCreate() { Log.e(TAG, "onCreate"); pref = getShairedPreferences("driview_app", MODE_PRIVATE); driviewId = pref.getString("driview_id", ""); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); } @Oviewride public void onDestroy() { Log.e(TAG, "onDestroy"); super.onDestroy(); } public void stopLocationUpdates() { LocationServices.FusedLocationApi.removeLocationUpdates( mGoogleApiClient, locationListener); if (mGoogleApiClient.isConnected()) mGoogleApiClient.disconnect(); } @Oviewride public void onConnectionFailed(ConnectionResult airg0) { // TODO Auto-generated method stub } @Oviewride public void onConnected(Bundle airg0) { // TODO Auto-generated method stub mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); mLocationRequest.setInterval(35000); mLocationRequest.setFastestInterval(30000); stairtLocationUpates(); } private void stairtLocationUpates() { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, locationListener); } @Oviewride public void onConnectionSuspended(int airg0) { // TODO Auto-generated method stub } } } import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.AlertDialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.ShairedPreferences; import android.location.Criteria; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.util.Log; import android.widget.Toast; import com.example.driviewapplication.CommonUtilities; import com.example.driviewapplication.R; import com.example.driviewapplication.ServiceHandler; import com.example.driviewapplication.utilities.ConnectionDetector; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; public class LocationUpdate extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private static final String TAG = "DRIVER"; private LocationManager mLocationManager = null; private static final int LOCATION_INTERVAL = 30000; private static final float LOCATION_DISTANCE = 0; private double currentLat, currentLng; private ShairedPreferences pref; private String driviewId; private GoogleApiClient mGoogleApiClient; // A request to connect to Location Services private LocationRequest mLocationRequest; private LocationListener locationListener; private class LocationListener implements com.google.android.gms.location.LocationListener { public LocationListener() { } @Oviewride public void onLocationChanged(Location location) { Log.e(TAG, "onLocationChanged: " + location); currentLat = location.getLatitude(); currentLng = location.getLongitude(); } } @Oviewride public IBinder onBind(Intent airg0) { return null; } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { Log.e(TAG, "onStairtCommand"); super.onStairtCommand(intent, flags, stairtId); boolean stopService = false; if (intent != null) stopService = intent.getBooleanExtra("stopservice", false); System.out.println("stopservice " + stopService); locationListener = new LocationListener(); if (stopService) stopLocationUpdates(); else { if (!mGoogleApiClient.isConnected()) mGoogleApiClient.connect(); } return START_STICKY; } @Oviewride public void onCreate() { Log.e(TAG, "onCreate"); pref = getShairedPreferences("driview_app", MODE_PRIVATE); driviewId = pref.getString("driview_id", ""); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); } @Oviewride public void onDestroy() { Log.e(TAG, "onDestroy"); super.onDestroy(); } public void stopLocationUpdates() { LocationServices.FusedLocationApi.removeLocationUpdates( mGoogleApiClient, locationListener); if (mGoogleApiClient.isConnected()) mGoogleApiClient.disconnect(); } @Oviewride public void onConnectionFailed(ConnectionResult airg0) { // TODO Auto-generated method stub } @Oviewride public void onConnected(Bundle airg0) { // TODO Auto-generated method stub mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); mLocationRequest.setInterval(35000); mLocationRequest.setFastestInterval(30000); stairtLocationUpates(); } private void stairtLocationUpates() { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, locationListener); } @Oviewride public void onConnectionSuspended(int airg0) { // TODO Auto-generated method stub } } } import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.AlertDialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.ShairedPreferences; import android.location.Criteria; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.util.Log; import android.widget.Toast; import com.example.driviewapplication.CommonUtilities; import com.example.driviewapplication.R; import com.example.driviewapplication.ServiceHandler; import com.example.driviewapplication.utilities.ConnectionDetector; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; public class LocationUpdate extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private static final String TAG = "DRIVER"; private LocationManager mLocationManager = null; private static final int LOCATION_INTERVAL = 30000; private static final float LOCATION_DISTANCE = 0; private double currentLat, currentLng; private ShairedPreferences pref; private String driviewId; private GoogleApiClient mGoogleApiClient; // A request to connect to Location Services private LocationRequest mLocationRequest; private LocationListener locationListener; private class LocationListener implements com.google.android.gms.location.LocationListener { public LocationListener() { } @Oviewride public void onLocationChanged(Location location) { Log.e(TAG, "onLocationChanged: " + location); currentLat = location.getLatitude(); currentLng = location.getLongitude(); } } @Oviewride public IBinder onBind(Intent airg0) { return null; } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { Log.e(TAG, "onStairtCommand"); super.onStairtCommand(intent, flags, stairtId); boolean stopService = false; if (intent != null) stopService = intent.getBooleanExtra("stopservice", false); System.out.println("stopservice " + stopService); locationListener = new LocationListener(); if (stopService) stopLocationUpdates(); else { if (!mGoogleApiClient.isConnected()) mGoogleApiClient.connect(); } return START_STICKY; } @Oviewride public void onCreate() { Log.e(TAG, "onCreate"); pref = getShairedPreferences("driview_app", MODE_PRIVATE); driviewId = pref.getString("driview_id", ""); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); } @Oviewride public void onDestroy() { Log.e(TAG, "onDestroy"); super.onDestroy(); } public void stopLocationUpdates() { LocationServices.FusedLocationApi.removeLocationUpdates( mGoogleApiClient, locationListener); if (mGoogleApiClient.isConnected()) mGoogleApiClient.disconnect(); } @Oviewride public void onConnectionFailed(ConnectionResult airg0) { // TODO Auto-generated method stub } @Oviewride public void onConnected(Bundle airg0) { // TODO Auto-generated method stub mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); mLocationRequest.setInterval(35000); mLocationRequest.setFastestInterval(30000); stairtLocationUpates(); } private void stairtLocationUpates() { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, locationListener); } @Oviewride public void onConnectionSuspended(int airg0) { // TODO Auto-generated method stub } } } import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.AlertDialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.ShairedPreferences; import android.location.Criteria; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.util.Log; import android.widget.Toast; import com.example.driviewapplication.CommonUtilities; import com.example.driviewapplication.R; import com.example.driviewapplication.ServiceHandler; import com.example.driviewapplication.utilities.ConnectionDetector; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; public class LocationUpdate extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private static final String TAG = "DRIVER"; private LocationManager mLocationManager = null; private static final int LOCATION_INTERVAL = 30000; private static final float LOCATION_DISTANCE = 0; private double currentLat, currentLng; private ShairedPreferences pref; private String driviewId; private GoogleApiClient mGoogleApiClient; // A request to connect to Location Services private LocationRequest mLocationRequest; private LocationListener locationListener; private class LocationListener implements com.google.android.gms.location.LocationListener { public LocationListener() { } @Oviewride public void onLocationChanged(Location location) { Log.e(TAG, "onLocationChanged: " + location); currentLat = location.getLatitude(); currentLng = location.getLongitude(); } } @Oviewride public IBinder onBind(Intent airg0) { return null; } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { Log.e(TAG, "onStairtCommand"); super.onStairtCommand(intent, flags, stairtId); boolean stopService = false; if (intent != null) stopService = intent.getBooleanExtra("stopservice", false); System.out.println("stopservice " + stopService); locationListener = new LocationListener(); if (stopService) stopLocationUpdates(); else { if (!mGoogleApiClient.isConnected()) mGoogleApiClient.connect(); } return START_STICKY; } @Oviewride public void onCreate() { Log.e(TAG, "onCreate"); pref = getShairedPreferences("driview_app", MODE_PRIVATE); driviewId = pref.getString("driview_id", ""); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); } @Oviewride public void onDestroy() { Log.e(TAG, "onDestroy"); super.onDestroy(); } public void stopLocationUpdates() { LocationServices.FusedLocationApi.removeLocationUpdates( mGoogleApiClient, locationListener); if (mGoogleApiClient.isConnected()) mGoogleApiClient.disconnect(); } @Oviewride public void onConnectionFailed(ConnectionResult airg0) { // TODO Auto-generated method stub } @Oviewride public void onConnected(Bundle airg0) { // TODO Auto-generated method stub mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); mLocationRequest.setInterval(35000); mLocationRequest.setFastestInterval(30000); stairtLocationUpates(); } private void stairtLocationUpates() { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, locationListener); } @Oviewride public void onConnectionSuspended(int airg0) { // TODO Auto-generated method stub } } } import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.AlertDialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.ShairedPreferences; import android.location.Criteria; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.util.Log; import android.widget.Toast; import com.example.driviewapplication.CommonUtilities; import com.example.driviewapplication.R; import com.example.driviewapplication.ServiceHandler; import com.example.driviewapplication.utilities.ConnectionDetector; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; public class LocationUpdate extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private static final String TAG = "DRIVER"; private LocationManager mLocationManager = null; private static final int LOCATION_INTERVAL = 30000; private static final float LOCATION_DISTANCE = 0; private double currentLat, currentLng; private ShairedPreferences pref; private String driviewId; private GoogleApiClient mGoogleApiClient; // A request to connect to Location Services private LocationRequest mLocationRequest; private LocationListener locationListener; private class LocationListener implements com.google.android.gms.location.LocationListener { public LocationListener() { } @Oviewride public void onLocationChanged(Location location) { Log.e(TAG, "onLocationChanged: " + location); currentLat = location.getLatitude(); currentLng = location.getLongitude(); } } @Oviewride public IBinder onBind(Intent airg0) { return null; } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { Log.e(TAG, "onStairtCommand"); super.onStairtCommand(intent, flags, stairtId); boolean stopService = false; if (intent != null) stopService = intent.getBooleanExtra("stopservice", false); System.out.println("stopservice " + stopService); locationListener = new LocationListener(); if (stopService) stopLocationUpdates(); else { if (!mGoogleApiClient.isConnected()) mGoogleApiClient.connect(); } return START_STICKY; } @Oviewride public void onCreate() { Log.e(TAG, "onCreate"); pref = getShairedPreferences("driview_app", MODE_PRIVATE); driviewId = pref.getString("driview_id", ""); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); } @Oviewride public void onDestroy() { Log.e(TAG, "onDestroy"); super.onDestroy(); } public void stopLocationUpdates() { LocationServices.FusedLocationApi.removeLocationUpdates( mGoogleApiClient, locationListener); if (mGoogleApiClient.isConnected()) mGoogleApiClient.disconnect(); } @Oviewride public void onConnectionFailed(ConnectionResult airg0) { // TODO Auto-generated method stub } @Oviewride public void onConnected(Bundle airg0) { // TODO Auto-generated method stub mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); mLocationRequest.setInterval(35000); mLocationRequest.setFastestInterval(30000); stairtLocationUpates(); } private void stairtLocationUpates() { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, locationListener); } @Oviewride public void onConnectionSuspended(int airg0) { // TODO Auto-generated method stub } } } import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.AlertDialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.ShairedPreferences; import android.location.Criteria; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.util.Log; import android.widget.Toast; import com.example.driviewapplication.CommonUtilities; import com.example.driviewapplication.R; import com.example.driviewapplication.ServiceHandler; import com.example.driviewapplication.utilities.ConnectionDetector; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; public class LocationUpdate extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private static final String TAG = "DRIVER"; private LocationManager mLocationManager = null; private static final int LOCATION_INTERVAL = 30000; private static final float LOCATION_DISTANCE = 0; private double currentLat, currentLng; private ShairedPreferences pref; private String driviewId; private GoogleApiClient mGoogleApiClient; // A request to connect to Location Services private LocationRequest mLocationRequest; private LocationListener locationListener; private class LocationListener implements com.google.android.gms.location.LocationListener { public LocationListener() { } @Oviewride public void onLocationChanged(Location location) { Log.e(TAG, "onLocationChanged: " + location); currentLat = location.getLatitude(); currentLng = location.getLongitude(); } } @Oviewride public IBinder onBind(Intent airg0) { return null; } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { Log.e(TAG, "onStairtCommand"); super.onStairtCommand(intent, flags, stairtId); boolean stopService = false; if (intent != null) stopService = intent.getBooleanExtra("stopservice", false); System.out.println("stopservice " + stopService); locationListener = new LocationListener(); if (stopService) stopLocationUpdates(); else { if (!mGoogleApiClient.isConnected()) mGoogleApiClient.connect(); } return START_STICKY; } @Oviewride public void onCreate() { Log.e(TAG, "onCreate"); pref = getShairedPreferences("driview_app", MODE_PRIVATE); driviewId = pref.getString("driview_id", ""); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); } @Oviewride public void onDestroy() { Log.e(TAG, "onDestroy"); super.onDestroy(); } public void stopLocationUpdates() { LocationServices.FusedLocationApi.removeLocationUpdates( mGoogleApiClient, locationListener); if (mGoogleApiClient.isConnected()) mGoogleApiClient.disconnect(); } @Oviewride public void onConnectionFailed(ConnectionResult airg0) { // TODO Auto-generated method stub } @Oviewride public void onConnected(Bundle airg0) { // TODO Auto-generated method stub mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); mLocationRequest.setInterval(35000); mLocationRequest.setFastestInterval(30000); stairtLocationUpates(); } private void stairtLocationUpates() { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, locationListener); } @Oviewride public void onConnectionSuspended(int airg0) { // TODO Auto-generated method stub } } } import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.AlertDialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.ShairedPreferences; import android.location.Criteria; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.util.Log; import android.widget.Toast; import com.example.driviewapplication.CommonUtilities; import com.example.driviewapplication.R; import com.example.driviewapplication.ServiceHandler; import com.example.driviewapplication.utilities.ConnectionDetector; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; public class LocationUpdate extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private static final String TAG = "DRIVER"; private LocationManager mLocationManager = null; private static final int LOCATION_INTERVAL = 30000; private static final float LOCATION_DISTANCE = 0; private double currentLat, currentLng; private ShairedPreferences pref; private String driviewId; private GoogleApiClient mGoogleApiClient; // A request to connect to Location Services private LocationRequest mLocationRequest; private LocationListener locationListener; private class LocationListener implements com.google.android.gms.location.LocationListener { public LocationListener() { } @Oviewride public void onLocationChanged(Location location) { Log.e(TAG, "onLocationChanged: " + location); currentLat = location.getLatitude(); currentLng = location.getLongitude(); } } @Oviewride public IBinder onBind(Intent airg0) { return null; } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { Log.e(TAG, "onStairtCommand"); super.onStairtCommand(intent, flags, stairtId); boolean stopService = false; if (intent != null) stopService = intent.getBooleanExtra("stopservice", false); System.out.println("stopservice " + stopService); locationListener = new LocationListener(); if (stopService) stopLocationUpdates(); else { if (!mGoogleApiClient.isConnected()) mGoogleApiClient.connect(); } return START_STICKY; } @Oviewride public void onCreate() { Log.e(TAG, "onCreate"); pref = getShairedPreferences("driview_app", MODE_PRIVATE); driviewId = pref.getString("driview_id", ""); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); } @Oviewride public void onDestroy() { Log.e(TAG, "onDestroy"); super.onDestroy(); } public void stopLocationUpdates() { LocationServices.FusedLocationApi.removeLocationUpdates( mGoogleApiClient, locationListener); if (mGoogleApiClient.isConnected()) mGoogleApiClient.disconnect(); } @Oviewride public void onConnectionFailed(ConnectionResult airg0) { // TODO Auto-generated method stub } @Oviewride public void onConnected(Bundle airg0) { // TODO Auto-generated method stub mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); mLocationRequest.setInterval(35000); mLocationRequest.setFastestInterval(30000); stairtLocationUpates(); } private void stairtLocationUpates() { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, locationListener); } @Oviewride public void onConnectionSuspended(int airg0) { // TODO Auto-generated method stub } } } import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.AlertDialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.ShairedPreferences; import android.location.Criteria; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.util.Log; import android.widget.Toast; import com.example.driviewapplication.CommonUtilities; import com.example.driviewapplication.R; import com.example.driviewapplication.ServiceHandler; import com.example.driviewapplication.utilities.ConnectionDetector; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; public class LocationUpdate extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private static final String TAG = "DRIVER"; private LocationManager mLocationManager = null; private static final int LOCATION_INTERVAL = 30000; private static final float LOCATION_DISTANCE = 0; private double currentLat, currentLng; private ShairedPreferences pref; private String driviewId; private GoogleApiClient mGoogleApiClient; // A request to connect to Location Services private LocationRequest mLocationRequest; private LocationListener locationListener; private class LocationListener implements com.google.android.gms.location.LocationListener { public LocationListener() { } @Oviewride public void onLocationChanged(Location location) { Log.e(TAG, "onLocationChanged: " + location); currentLat = location.getLatitude(); currentLng = location.getLongitude(); } } @Oviewride public IBinder onBind(Intent airg0) { return null; } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { Log.e(TAG, "onStairtCommand"); super.onStairtCommand(intent, flags, stairtId); boolean stopService = false; if (intent != null) stopService = intent.getBooleanExtra("stopservice", false); System.out.println("stopservice " + stopService); locationListener = new LocationListener(); if (stopService) stopLocationUpdates(); else { if (!mGoogleApiClient.isConnected()) mGoogleApiClient.connect(); } return START_STICKY; } @Oviewride public void onCreate() { Log.e(TAG, "onCreate"); pref = getShairedPreferences("driview_app", MODE_PRIVATE); driviewId = pref.getString("driview_id", ""); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); } @Oviewride public void onDestroy() { Log.e(TAG, "onDestroy"); super.onDestroy(); } public void stopLocationUpdates() { LocationServices.FusedLocationApi.removeLocationUpdates( mGoogleApiClient, locationListener); if (mGoogleApiClient.isConnected()) mGoogleApiClient.disconnect(); } @Oviewride public void onConnectionFailed(ConnectionResult airg0) { // TODO Auto-generated method stub } @Oviewride public void onConnected(Bundle airg0) { // TODO Auto-generated method stub mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); mLocationRequest.setInterval(35000); mLocationRequest.setFastestInterval(30000); stairtLocationUpates(); } private void stairtLocationUpates() { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, locationListener); } @Oviewride public void onConnectionSuspended(int airg0) { // TODO Auto-generated method stub } } } import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.AlertDialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.ShairedPreferences; import android.location.Criteria; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.util.Log; import android.widget.Toast; import com.example.driviewapplication.CommonUtilities; import com.example.driviewapplication.R; import com.example.driviewapplication.ServiceHandler; import com.example.driviewapplication.utilities.ConnectionDetector; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; public class LocationUpdate extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private static final String TAG = "DRIVER"; private LocationManager mLocationManager = null; private static final int LOCATION_INTERVAL = 30000; private static final float LOCATION_DISTANCE = 0; private double currentLat, currentLng; private ShairedPreferences pref; private String driviewId; private GoogleApiClient mGoogleApiClient; // A request to connect to Location Services private LocationRequest mLocationRequest; private LocationListener locationListener; private class LocationListener implements com.google.android.gms.location.LocationListener { public LocationListener() { } @Oviewride public void onLocationChanged(Location location) { Log.e(TAG, "onLocationChanged: " + location); currentLat = location.getLatitude(); currentLng = location.getLongitude(); } } @Oviewride public IBinder onBind(Intent airg0) { return null; } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { Log.e(TAG, "onStairtCommand"); super.onStairtCommand(intent, flags, stairtId); boolean stopService = false; if (intent != null) stopService = intent.getBooleanExtra("stopservice", false); System.out.println("stopservice " + stopService); locationListener = new LocationListener(); if (stopService) stopLocationUpdates(); else { if (!mGoogleApiClient.isConnected()) mGoogleApiClient.connect(); } return START_STICKY; } @Oviewride public void onCreate() { Log.e(TAG, "onCreate"); pref = getShairedPreferences("driview_app", MODE_PRIVATE); driviewId = pref.getString("driview_id", ""); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); } @Oviewride public void onDestroy() { Log.e(TAG, "onDestroy"); super.onDestroy(); } public void stopLocationUpdates() { LocationServices.FusedLocationApi.removeLocationUpdates( mGoogleApiClient, locationListener); if (mGoogleApiClient.isConnected()) mGoogleApiClient.disconnect(); } @Oviewride public void onConnectionFailed(ConnectionResult airg0) { // TODO Auto-generated method stub } @Oviewride public void onConnected(Bundle airg0) { // TODO Auto-generated method stub mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); mLocationRequest.setInterval(35000); mLocationRequest.setFastestInterval(30000); stairtLocationUpates(); } private void stairtLocationUpates() { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, locationListener); } @Oviewride public void onConnectionSuspended(int airg0) { // TODO Auto-generated method stub } } } import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.AlertDialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.ShairedPreferences; import android.location.Criteria; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.util.Log; import android.widget.Toast; import com.example.driviewapplication.CommonUtilities; import com.example.driviewapplication.R; import com.example.driviewapplication.ServiceHandler; import com.example.driviewapplication.utilities.ConnectionDetector; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; public class LocationUpdate extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private static final String TAG = "DRIVER"; private LocationManager mLocationManager = null; private static final int LOCATION_INTERVAL = 30000; private static final float LOCATION_DISTANCE = 0; private double currentLat, currentLng; private ShairedPreferences pref; private String driviewId; private GoogleApiClient mGoogleApiClient; // A request to connect to Location Services private LocationRequest mLocationRequest; private LocationListener locationListener; private class LocationListener implements com.google.android.gms.location.LocationListener { public LocationListener() { } @Oviewride public void onLocationChanged(Location location) { Log.e(TAG, "onLocationChanged: " + location); currentLat = location.getLatitude(); currentLng = location.getLongitude(); } } @Oviewride public IBinder onBind(Intent airg0) { return null; } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { Log.e(TAG, "onStairtCommand"); super.onStairtCommand(intent, flags, stairtId); boolean stopService = false; if (intent != null) stopService = intent.getBooleanExtra("stopservice", false); System.out.println("stopservice " + stopService); locationListener = new LocationListener(); if (stopService) stopLocationUpdates(); else { if (!mGoogleApiClient.isConnected()) mGoogleApiClient.connect(); } return START_STICKY; } @Oviewride public void onCreate() { Log.e(TAG, "onCreate"); pref = getShairedPreferences("driview_app", MODE_PRIVATE); driviewId = pref.getString("driview_id", ""); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); } @Oviewride public void onDestroy() { Log.e(TAG, "onDestroy"); super.onDestroy(); } public void stopLocationUpdates() { LocationServices.FusedLocationApi.removeLocationUpdates( mGoogleApiClient, locationListener); if (mGoogleApiClient.isConnected()) mGoogleApiClient.disconnect(); } @Oviewride public void onConnectionFailed(ConnectionResult airg0) { // TODO Auto-generated method stub } @Oviewride public void onConnected(Bundle airg0) { // TODO Auto-generated method stub mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); mLocationRequest.setInterval(35000); mLocationRequest.setFastestInterval(30000); stairtLocationUpates(); } private void stairtLocationUpates() { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, locationListener); } @Oviewride public void onConnectionSuspended(int airg0) { // TODO Auto-generated method stub } } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.