2012-04-16 111 views
-2

如何使用WiFi获取当前位置? 在我的项目使用GPS我可以得到当前的位置... 如何在Android中使用网络服务?使用wifi获取当前位置?

LocationManager mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 
LocationListener currentlocation = new CurrentLocation(); 
     mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, 
       currentlocation); 

但我想要当前位置WiFi? 任何人都可以帮助我获得使用WiFi的当前位置?

+5

@Nanne如果我不什么都1 ....除了wifi的是好多了,可以控制 – 2012-04-16 10:12:19

回答

1

尝试使用NETWORK_PROVIDER

请注意,你将不得不修改您的AndroidManifest.xml以及加入:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
+1

ACCESS_FINE_LOCATION意味着ACCESS_COARSE_LOCATION。没有必要添加两者。 – 2013-11-04 14:01:49