2010-08-13 47 views
0

我用this教程来编写我的应用程序。我使用DDMS位置管理器虚拟地更改我的位置。GPS:loc.getLatitude /经度始终为0.0

不幸的是,我总是得到一个位置为0.0长和纬。即使我稍后在prog中使用locationchanged-method切换它,我也会得到0.0。

代码是这样的:

@Override 
public void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    //---use the LocationManager class to obtain GPS locations--- 
    lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);  
    locationListener = new MyLocationListener(); 
    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); 

    Location lastLoc = lm.getLastKnownLocation("gps"); 

    curLocation = "Standort: \nLatitude: " + lastLoc.getLatitude() + "\nLongitude: " + lastLoc.getLongitude(); 

    upperText = (TextView) findViewById(R.id.TextView01); 
    upperText.setText(curLocation); 
} 

@Override 
    public void onLocationChanged(Location loc) 
    { 
     if (loc != null) { 
      Toast.makeText(getBaseContext(), 
       "Location changed : Lat: " + loc.getLatitude() + 
       " Lng: " + loc.getLongitude(), 
       Toast.LENGTH_SHORT).show(); 
     } 

     if (loc != null) 
     { 
      upperText.setText(curLocation + "\n\nStandort: \nLatitude: " + loc.getLatitude() 
        + "\nLongitude: " + loc.getLongitude()); 
     } 
    } 

数据不完整,但我不知道是什么...:/

我会,如果有人真的很高兴可以帮助=)!

+0

你传递纬度GPS信号闪烁, /经度:48.020203或48,020203? – Sephy 2010-08-13 09:48:51

+0

在DDMS中,我写了48.020203。所以一点。我使用了位置管理器的默认输入,它也没有工作。 – Vivi 2010-08-13 10:00:05

回答

0

去地图默认的应用程序,允许用户允许的经度和纬度的选项。在我们的应用程序时,当它停止,我们会得到纬度和longitude.It工作对我来说