0
我試圖實現從活動返回而不需要刷新屏幕。據我看到的,有4個可能的狀態來處理:onResume()沒有調用setupWebView()後從活動回調
- 兩者「使用無線網絡」和「使用GPS衛星」將被禁用(用戶被定向到我的位置偏好和不允許繼續如果其中任何一個被禁用)
- 其中一個兩個被使能(1 2的可能性) 3,兩者都啓用
我的問題是,在我的應用程序從其他活動回國後,setupWebView()被調用每次導致屏幕刷新延遲。
刷新從偏好返回(例如啓用後得到修復後的GPS),但肯定不是在從活動返回後返回,因爲重新繪製屏幕的時間延遲會分散注意力並減慢我的工作流程應用程序。
有人請指教如何在我的onResume()內處理這個以避免所有setupWebview調用。
這裏是我的onResume()我的主要活動中的代碼:
@Override
protected void onResume() {
if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)
&& !locationManager
.isProviderEnabled(LocationManager.NETWORK_PROVIDER))
createMyLocationDisabledAlert();
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 500, 0, this);
mostRecentLocation = locationManager
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (mostRecentLocation != null)
setupWebView();
else {
mostRecentLocation = locationManager
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
setupWebView();
}
}
else if (locationManager
.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
locationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER, 500, 0, this);
mostRecentLocation = locationManager
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (mostRecentLocation != null)
setupWebView();
else {
mostRecentLocation = locationManager
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
setupWebView();
}
}
// locationManager.requestLocationUpdates(provider, 500, 0, this);
// mostRecentLocation = locationManager.getLastKnownLocation(provider);
// } else
// mostRecentLocation = locationManager
// .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
super.onResume();
}
這很有道理。我會試一試,謝謝。 – qubz 2010-12-05 13:01:45