String logloc ="";
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location!=null) {
double longitude = location.getLongitude();
double latitude = location.getLatitude();
logloc = String.valueOf(latitude)+","+String.valueOf(longitude);
notfi(logloc);
}
在上面的代码中,即使我的 gps 设备处于打开状态,并且在建筑物外和建筑物内,我的位置总是为空,我只得到空值,请帮助我运行此代码