2014-02-26 63 views
1
public void getCellLocation1() { 

    try { 
     LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 

     Location location = null; 

     List<String> providers = manager.getAllProviders(); 

     for (String provider : providers) { 
      location = manager.getLastKnownLocation(provider); 
     } 
     TextView celllocation = (TextView) findViewById(R.id.txtNewLoc); 
     String stlocation = location.toString(); 
     celllocation.setText(stlocation); 
    } catch (Exception a) { 
     Log.d("ERRR", "Could not get location", a); 
    } 
} 

這是返回:Android的的LocationManager類返回更多信息於預期

Location[network 37.xxxxxx,-122.xxxxxx acc=20 et=+4h41m6s233ms {Bundle[mParcelledData.dataSize=548]}] 

現在我明白了,我越來越長,緯度,精度等級和估計的時間。它看起來像我得到這個數組。無論如何要打破這一點?我真的只會喜歡經緯度,以便我可以在URI中使用它來調用谷歌地圖,但任何信息都會很好。

回答

2
String sLat = Double.toString(location.getLatitude()); 
     String sLong = Double.toString(location.getLongitude()); 
     String Speed = Double.toString(location.getSpeed()); 
     String sAlt = Double.toString(location.getAltitude()); 
     String sTime = Double.toString(location.getTime()); 

這是你得到所有從的LocationManager

+0

的信息請如果答案是有幫助的,你接受的答案...任何其他的問題,我會很樂意幫助你的方式...... – geekCode

相關問題