I have a AsyncTask where it checks for the Accelerometer data. When ever i detects that Accelerometer is giving larger values i need to start the GPS recording.
private LocationManager mlocManager;
private GPSLocationListener mlocListener;
..
mlocManager = (LocationManager)context.getSystemService(context.LOCATION_SERVICE);
mlocListener = new GPSLocationListener();
..
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 100, mlocListener);
mlocManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000, 100, mlocListener);
How to make this running? The errors i get are
error occured while executing doInBackground()
Can't create handler inside thread that has not called Looper.prepare()
AsyncTask doesn’t run on the Looper thread and hence the problem, You may want to use Handlers as they run with the Looper thread and hence such errors wont occur.