简体   繁体   English

打开天气地图android位置管理器

[英]Open weather Map android Location manager

I have tried to implement the openweather map api following the android tutorial. 我已经尝试在android教程之后实现openweather map api。 Which only shows default hard coded city and providing user city preferences. 仅显示默认的硬编码城市并提供用户城市首选项。 But my intention is to parse the api based on Location/ gps services provided by android permissions. 但我的意图是根据android权限提供的Location / gps服务来解析api。

Kindly please help me with code to request weather result based on current location of the user. 请帮助我提供代码,以根据用户的当前位置请求天气结果。

The main permissions you need are android.permission.ACCESS_COARSE_LOCATION or android.permission.ACCESS_FINE_LOCATION. 您需要的主要权限是android.permission.ACCESS_COARSE_LOCATION或android.permission.ACCESS_FINE_LOCATION。

Only fine location will allow you access to gps data, and allows you access to everything else coarse location gives. 只有精细位置才能访问gps数据,并且可以访问粗略位置提供的所有其他信息。 You can use the methods of the LocationManager to acquire location data from gps and cell tower sources already,so no need to work out this information yourself. 您可以使用LocationManager的方法从gps和基站信号源中获取位置数据,因此无需自己计算此信息。

Android Manifest Permissions: http://developer.android.com/reference/android/Manifest.permission.html Android清单权限: http//developer.android.com/reference/android/Manifest.permission.html

You can get this permission and find the location which can be used in weather api. 您可以获取此权限,并找到可以在Weather API中使用的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM