我是Android开发的新手。
R&D
GPS system.
进行操作
Google Map view
,当前位置,GPS
跟踪和路径等功能。 答案 0 :(得分:1)
我使用以下由我创建的库跟踪GPS Co-Ordinates,
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
public class LocListener implements LocationListener
{
private static double lat =0.0;
private static double lon = 0.0;
private static double alt = 0.0;
private static double speed = 0.0;
public static double getLat()
{
return lat;
}
public static double getLon()
{
return lon;
}
public static double getAlt()
{
return alt;
}
public static double getSpeed()
{
return speed;
}
@Override
public void onLocationChanged(Location location)
{
lat = location.getLatitude();
lon = location.getLongitude();
alt = location.getAltitude();
speed = location.getSpeed();
}
@Override
public void onProviderDisabled(String provider) {}
@Override
public void onProviderEnabled(String provider) {}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {}
}
使用以下方式,您可以从上面的类中获取纬度和经度详细信息
String latitude,longitude;
latitude = String.valueOf( LocListener.getLat() );
longitude = String.valueOf( LocListener.getLon() );
用于获取gps,您需要在AndroidManifest.xml中提供gps权限,如下所示,
<uses-permission android:name="android.permission.ACCESS_GPS"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>