网络位置不起作用

时间:2014-01-29 12:33:10

标签: android android-location

我在我的应用中获取网络位置时遇到了一个奇怪的问题。每隔一段时间(当时还没找到),当试图通过我的应用程序获取位置时,网络位置停止工作(我设法只获得GPS位置)。解决这个问题的唯一方法是重新启动手机(甚至没有强行关闭我的应用程序)。请注意,我在不同的手机上遇到过这个错误测试,这意味着它不是某个手机的问题。有什么建议吗?

01-29 16:17:04.792: D/Starling.LocationHandler(1431): starting to listen to location
01-29 16:17:04.802: V/GmsNetworkLocationProvi(988): onSetRequest: ProviderRequestUnbundled, reportLocation is true and interval is 0
01-29 16:17:04.802: V/GmsNetworkLocationProvi(988): SET-REQUEST
01-29 16:17:04.802: V/GmsNetworkLocationProvi(988): in Handler: ProviderRequestUnbundled, reportLocation is true and interval is 0
01-29 16:17:04.802: D/Starling.HomeActivity(1431): after startLocationListener
01-29 16:17:04.842: V/SearchControllerCache(4077): disposing SearchController
01-29 16:17:04.862: D/dalvikvm(4077): threadid=42: thread exiting, not yet detached (count=0)
01-29 16:17:04.862: D/dalvikvm(4077): threadid=32: thread exiting, not yet detached (count=0)
01-29 16:17:04.862: D/dalvikvm(4077): threadid=49: thread exiting, not yet detached (count=0)
01-29 16:17:30.380: I/dalvikvm(1417): Jit: resizing JitTable from 4096 to 8192
01-29 16:17:30.770: D/Starling.LocationHandler(1431): location change gps
01-29 16:17:30.820: D/Starling.LocationHandler(1431): turning off location listener
01-29 16:17:30.820: V/GmsNetworkLocationProvi(988): onSetRequest: ProviderRequestUnbundled, reportLocation is true and interval is 86400000
01-29 16:17:30.820: V/GmsNetworkLocationProvi(988): SET-REQUEST
01-29 16:17:30.820: V/GmsNetworkLocationProvi(988): in Handler: ProviderRequestUnbundled, reportLocation is true and interval is 86400000

如您所见,我没有从网络中获取该位置......

public void startLocationListener(LocationListenerManager manager){

        this.manager = manager;
        Log.d(TAG, "starting to listen to location");
        mlocManager =  (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);

        gpsEnabled = mlocManager.isProviderEnabled(LocationManager.GPS_PROVIDER);



        mlocManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
        mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);

private class MyLocationListener implements LocationListener{
        @Override
        public void onLocationChanged(Location newLocation) {

            Log.d(TAG, "location change " + newLocation.getProvider());

                    location = newLocation;

                location.getLongitude() + " " + location.getLatitude() );
                Log.d(TAG,"onLocationChanged "+newLocation.getLatitude()+" "+newLocation.getLongitude());
                manager.onLocationChanged(newLocation);
                endLocationListener();


        }

0 个答案:

没有答案