我正在制作一个应用程序,我必须在其中获取设备的高度,我的代码如下:
public class MyLocationListener implements LocationListener
{
public void onLocationChanged(Location loc)
{
try
{
System.out.println("............ ..............................Location changedin 11");
latitude = loc.getLatitude();
longitude = loc.getLongitude();
altitude=loc.getAltitude();
System.out.println("alt"+altitude);
System.out.println("latitude123 "+latitude);
System.out.println("longi: "+longitude);
System.out.println("longitude curr_lon");
loc.getAccuracy();
System.out.println("loc"+loc.getAccuracy());
latitudee=(TextView)findViewById(R.id.latitudee);
latitudee.setText(""+latitude);
longitudee=(TextView)findViewById(R.id.longitudee);
longitudee.setText(""+longitude);
accuracyy=(TextView)findViewById(R.id.accuracyy);
accuracyy.setText(""+loc.getAccuracy());
System.out.println("alti:"+altitude); // alti is coming out to be 0.0
}
catch (Exception e1) {
e1.printStackTrace();
}
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
}
高度的值即将变为0.0。任何帮助将不胜感激。