I'm new to android, bear it with me.
I've a TimerTask for which I define run() inside the Service. Inside run(), I'm calling
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
LOCATION_UPDATES_MIN_TIME_MS, LOCATION_UPDATES_MIN_DISTANCE_M, gpsListener);
and it complains that can't create Handler, since I believe its a background thread. How do I solve it?
Edit: Code snippet
locationTask = new TimerTask() {
@Override
public void run() {
Log.d(Commands.TAG, "Running location Task");
myLocationProvider = new MyLocationProvider(locationManager, handler, MyService.this);
myLocationProvider.start();
myLocationProvider.stop();
}
};
and later its Scheduled as below:
locationTimer = new Timer();
locationTimer.schedule(locationTask, 10000, cmds.getAlertInterval()*60);
and when .start is called, requestLocationUpdates() fails