开发者

Cannot get position from Network

开发者 https://www.devze.com 2023-02-26 03:31 出处:网络
I\'m trying to get the location based on network. I\'ve declared in the manifest I\'ve registered the listener and requested location updates :

I'm trying to get the location based on network. I've declared in the manifest

I've registered the listener and requested location updates :

 locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,  listener);

The problem is that I don't receive any location updates in listener's onLocationChanged() This only happens for devices with API level 8 and above Samsung Galaxy S , Google Nexus One for pre 2.2 devices (e.g Htc Desire) works fine.

after requesting updates from network provider I've checked if NETWORK_PROVIDER is enabled:

 Criteria criteria =new Criteria();

 criteria.setAccuracy(Criteria.ACC开发者_如何学CURACY_FINE);

 Log.d(TAG,"best app provider:"+locationManager.getBestProvider(criteria, true));

 Log.d(TAG,"is network enabled:"+locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER));

and returned: best app provider:network is network enabled:true

so everything seems to be fine except no position is received by the listener.

can anyone give me hint if something changed in the api? do I have to set up something else?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号