【问题标题】:Get current location using wifi?使用wifi获取当前位置?
【发布时间】:2012-04-16 10:05:18
【问题描述】:

如何使用 WiFi 获取当前位置? 在我使用 gps 的项目中,我可以获得当前位置... 如何在android中使用网络服务?

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

但我想要当前位置的 WiFi? 谁能帮助我使用 WiFi 获取当前位置?

【问题讨论】:

  • @Nanne 如果我没有 1 怎么办……除了 wifi 更好,可以控制

标签: android android-wifi


【解决方案1】:

尝试使用NETWORK_PROVIDER

请注意,您还必须修改您的 AndroidManifest.xml,并添加:

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

【讨论】:

  • ACCESS_FINE_LOCATION 意味着 ACCESS_COARSE_LOCATION。两者都不需要添加。
猜你喜欢
  • 2011-02-11
  • 1970-01-01
  • 2016-12-01
  • 2015-11-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多