获取经度和纬度值更快 [英] Getting longitude and latitude values faster

查看:173
本文介绍了获取经度和纬度值更快的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个android应用程序,我想获取android手机的经纬度。我获取经纬度的代码在一段时间后会给出值。有时候,它根本没有提供价值。任何人都可以帮助我做些什么!

I am developing an application in android and I want to get the latitude and longitude of the android mobile. My code for getting latitude and longitude is giving values after some time. And sometimes, it doesn't give values at all. Can anyone help me what can be done!

推荐答案

您需要添加此代码才能获取当前位置。请确保您提供所有权限

You need to add this code for getting te current location. make sure you give all the permissions

Location Manager location =  locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if(location!=null) 
{
 latitude = location.getLatitude();
 longitude = location.getLongitude();
}

这篇关于获取经度和纬度值更快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆