i am developing a application which will send location updates continuously from a background service. i tried following code.
public class LocationService e
Try this:
@Override
public void onCreate() {
//creating log file in mobile
appendLog(DateFormat.getDateTimeInstance().format(new Date()) + ": Service created:", com.example.locationservice.Constants.LOG_FILE);
mLocationClient = new LocationClient(getApplicationContext(), this,this);
}
replace your onStart with:
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
mLocationClient.connect();
}
and:
@Override
public void onConnected(Bundle arg0) {
mLocationRequest = LocationRequest.create();
mLocationRequest.setInterval(5*1000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationClient.requestLocationUpdates(mLocationRequest, this);
}
Invoke your service:
startService(yourServiceIntent);
You can also check my code here