當我試圖讓我的位置在三星Galaxy S3上時,我的應用程序崩潰。它可以在我測試過的其他三款手機上使用。我只在三星Galaxy S3上有遠程測試人員,所以我不能得到錯誤信息。這裏是我的代碼:android getlastknown位置在三星Galaxy S3 s3崩潰
Location finalLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
locationManager.removeUpdates(locationListenerGps);
locationManager.removeUpdates(locationListenerNetwork);
Location net_loc=null, gps_loc=null;
if(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
gps_loc=locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if(locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER))
net_loc=locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
//if there are both values use the latest one
if(gps_loc!=null && net_loc!=null){
if(gps_loc.getTime()>net_loc.getTime())
finalLocation = gps_loc;
else
finalLocation = net_loc;
}
if(gps_loc!=null){
finalLocation = gps_loc;
}
if(net_loc!=null){
finalLocation = net_loc;
}
讓他們安裝一個logcat的應用程序,讓你的崩潰日誌... – dymmeh
是的,我會努力的!謝謝 – user1828049
Android應用程序不使用Google Maps API V3。 (標籤替換) – Marcelo