我试图根据WiFi/3G/4G连接获取位置,但它总是返回0.0为latitude and longitude.如果使用相同的代码GPS ON然后它可以工作,所以从4.4开始改变了一些东西.
也尝试了以下链接,但它也没有工作.
http://www.androidhive.info/2015/02/android-location-api-using-google-play-services/
public class GPSTracker extends Service implements LocationListener {
private static final String TAG = "GPSTracker";
private final Context mContext;
boolean isGPSEnabled = false;
boolean isNetworkEnabled = false;
boolean canGetLocation = false;
Location location; // location
double latitude; // latitude
double longitude; // longitude
double speed;
double altitude;
double bearings;
// The minimum distance to change Updates in meters
private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 1; // …Run Code Online (Sandbox Code Playgroud)