为了账号安全,请及时绑定邮箱和手机立即绑定

如何在android中获取当前位置的经纬度

如何在android中获取当前位置的经纬度

守着一只汪 2019-08-26 10:09:08
如何在android中获取当前位置的经纬度在我的应用程序中,我在应用程序打开时获取当前位置的纬度和经度,但在应用程序关闭时不会。我正在使用Service类来获取我的应用程序中的当前位置纬度和经度。即使应用程序关闭,请告诉我如何获取当前位置的纬度和经度
查看完整描述

3 回答

?
12345678_0001

TA贡献1802条经验 获得超5个赞

试试这个,希望每次位置变化时它都会帮助您获取当前位置。

public class MyClass implements LocationListener {
    double currentLatitude, currentLongitude;

    public void onLocationChanged(Location location) {
        currentLatitude = location.getLatitude();
        currentLongitude = location.getLongitude();
    }}


查看完整回答
反对 回复 2019-08-26
  • 3 回答
  • 0 关注
  • 790 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信