[问题] 使用者定位(经度,纬度)问题,请益

楼主: wheado (principal component QQ)   2018-04-03 18:07:30
我想做一个练习
这个练习是打开APP按下按钮之后
显示出我目前的经纬度
我找了不少的教学视频还有google-sample
但是都没办法成功
最后拼拼凑凑弄了一个可以执行的
但是经纬度似乎不对的而且不管在哪里都一样
以下是主要的code
https://ideone.com/K0qi2l
网络上有许多方法
例如: GPS, fused location provider, locationManaget
这个部份很多我都试过
但不知道是版本还是API更新的太快
不知道怎么改Q.Q
Layout Manifest gradle 在这
https://ideone.com/pfbhYM
https://ideone.com/yrFdzj
https://ideone.com/nUKF9P
这里理论上应该是没问题
关键字
Getting the Last Known Location
Kotlin Android Tutorial - Google Location Services
How to Get Current Location Latitude and Longitude in Android Studio Example
https://www.youtube.com/watch?v=XQJiiuk8Feo
这个离成功最靠近-.-
https://github.com/googlesamples
Google官方的?
新手恳请指教,感激不尽。
作者: cf1064 (蚵仔)   2018-04-03 21:14:00
android 6.0以上有另外要求给予权限吗?
楼主: wheado (principal component QQ)   2018-04-03 21:27:00
好像有,但我找不到getLocation函数
作者: j19930307 (钙世英雄)   2018-04-04 23:40:00
你是用模拟器还是手机测试?我用你的code下去跑 经纬度是正常的〃不管在哪里都一样〃 是指在不同地方所显示的经纬度都是一样数值吗?

Links booklink

Contact Us: admin [ a t ] ucptt.com