Android LocationListener的位置看起来像“ 50。********,9。********”

时间:2018-08-14 10:19:02

标签: android location locationlistener

我正在使用“ LocationListener”。

当我的应用从功能“ onLocationChanged”获取结果时 然后我的数据看起来就像

Location[netowrk 50*****, 19******** ac=12312ms alt=3019]

有人知道为什么吗? 以及如何解决?

1 个答案:

答案 0 :(得分:0)

清单

  <uses-feature android:name="android.hardware.location.network"/>
    <uses-feature android:name="android.hardware.location.gps" />   
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />



  private class LocationListener implements android.location.LocationListener{
    Location mLastLocation;
    public LocationListener(String provider)
    {
        Log.e(TAG, "LocationListener " + provider);
        mLastLocation = new Location(provider);
    }
    @Override
    public void onLocationChanged(Location location)
    {

        Log.e(TAG, "onLocationChanged: " + location);
        mLastLocation.set(location);

        String location_end = ""+location;
        saveToFile("/data/data/com.strziga.spolem/gps.txt", location_end);


    }
    @Override
    public void onProviderDisabled(String provider)
    {
        Log.e(TAG, "onProviderDisabled: " + provider);
    }
    @Override
    public void onProviderEnabled(String provider)
    {
        Log.e(TAG, "onProviderEnabled: " + provider);
    }
    @Override
    public void onStatusChanged(String provider, int status, Bundle extras)
    {
        Log.e(TAG, "onStatusChanged: " + provider);
    }
}
LocationListener[] mLocationListeners = new LocationListener[] {
        new LocationListener(LocationManager.GPS_PROVIDER),
        new LocationListener(LocationManager.NETWORK_PROVIDER)
};