제대로 작동하려면 일정 기간 동안 코드를 유지해야하는 코드 조각이 있습니다. 그러나 35 초가 시작될 때 코드가 멈추지 만 원하는대로 작동하지 않습니다. IE는 내가 원하는 출력을 얻지 못한다."일시 중지"앱이 작동하지만 원하는 방식으로 작동하지 않습니다.
여기 제가 작업하고있는 코드가 있습니다.
LocationManager mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
LocationListener mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
mlocListener);
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
1000L, 1.0f, (LocationListener) this);
boolean isGPS = locationManager
.isProviderEnabled(LocationManager.GPS_PROVIDER);
// Methods to make the code wait 35 seconds
int time = 35000;
try {
Thread.sleep(time);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Intent WriteOut = new Intent(context, WriteOut.class);
WriteOut.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(WriteOut);
나는 시스템이/발사 장치의 GPS 신호를 획득 할 수있는 기회를 한 후 현재의 GPS 좌표를 출력하려합니다.
이 문제를 해결하는 방법에 대한 팁은 내가 분명히 잘못된 일을하고 있기 때문에 훌륭합니다.
이'Activity' 내부 코드가 도움이되는지 알려주세요? – codeMagic
아니요. 그것의 외부/클래스에 표시됩니다. 그것이 당신이 찾고있는 대답이라면. @codeMagic – CodeMonkeyAlx
그게 도움이되고 싶다. – codeMagic