0
Accelerometer 데이터를 확인하는 AsyncTask가 있습니다. 가속도계가 더 큰 값을 제공한다는 것을 발견하면 GPS 기록을 시작해야합니다.AsyncTask에서 "requestLocationUpdates"를 호출하는 방법
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);
어떻게 실행하나요? 내가 얻는 오류가
error occured while executing doInBackground()
Can't create handler inside thread that has not called Looper.prepare()
왜 AsyncTask를 사용해야합니까? AsyncTask에서 실제로 사용하려면 onPreExecute() 내에서 사용하면 UI 스레드에서 실행됩니다. –
이 링크 확인 http://stackoverflow.com/questions/6961611/android-requestlocationupdates-throws-exception – Antrromet