我的應用程序使用進度對話框,讓我的用戶知道,如圖所示位置監聽器目前正在尋找他們的當前座標:LocationListener的用了Thread.Sleep
ProgressDialog searching;
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationListener = new GPSLocationListener();
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
0, locationListener);
searching = ProgressDialog.show(this, null, "Gaining GPS posistion...", false,true);
這是偉大的,但我想設置一個時間限制這可以運行。我可以使用簡單的Thread.Sleep靜態實例設置 - 例如 - 20秒?這會檢查我的位置對象是否仍然爲空,然後取消搜索?
我可以同時運行位置偵聽器和thread.sleep嗎?我已經看過Thread.Sleep的Oracle註釋,但我仍然不能100%確定。