Android的:获取纬度和经度 [英] Android: Getting Latitude and Longitude

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

问题描述

是否有可能得到纬度和放大器; LNG没有去户外?我现在的情况是,用户将不得不户外为了得到自己的位置,在这也需要相当长的时间让他们得到一个。我希望我的用户能够得到他们的位置室内。

Is it possible to get the Lat & Lng without going outdoor? My current situation is that user would have to be outdoor in order to get their location , in which also takes quite a long time for them to get one. I want my user to be able to get their location indoor.

推荐答案

是的,它是可能的,采取从下code提示:

Yes it is possible , take hint from following code:

try {
            gps_enabled = locManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        } catch (Exception ex) {
        }
        try {
            network_enabled = locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
        } catch (Exception ex) {
        }

        if (!gps_enabled && !network_enabled) {
             // show alert 
        }
        if (network_enabled) {
            locManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locListener);
        }
        if (gps_enabled) {
            locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locListener);
        }

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

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