Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android中,如何在没有互联网连接的情况下获取当前的纬度和经度?_Android_Google Maps_Gps_Location_Latitude Longitude - Fatal编程技术网

在android中,如何在没有互联网连接的情况下获取当前的纬度和经度?

在android中,如何在没有互联网连接的情况下获取当前的纬度和经度?,android,google-maps,gps,location,latitude-longitude,Android,Google Maps,Gps,Location,Latitude Longitude,我正在创建一个与位置相关的应用程序,所以我需要在没有互联网连接的情况下获取当前的纬度和经度 请帮帮我。我是位置管理器的新手。 谢谢你的建议。 感谢您的问候。有两种方法可以获取位置 1) 网络供应商 2) 全球定位系统供应商 要通过GPS提供商(无互联网)获取位置,请使用以下代码中提到的LocationManager.GPS\u Provider locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVI

我正在创建一个与位置相关的应用程序,所以我需要在没有互联网连接的情况下获取当前的纬度和经度

请帮帮我。我是位置管理器的新手。 谢谢你的建议。
感谢您的问候。

有两种方法可以获取位置

1) 网络供应商

2) 全球定位系统供应商

要通过GPS提供商(无互联网)获取位置,请使用以下代码中提到的
LocationManager.GPS\u Provider

locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE);
locationManager.requestLocationUpdates(
                                    LocationManager.GPS_PROVIDER,
                                    MIN_TIME_BW_UPDATES,
                                    MIN_DISTANCE_CHANGE_FOR_UPDATES, this);

if (locationManager != null) {

            location =locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

                            if (location != null) {
                                latitude = location.getLatitude();
                                longitude = location.getLongitude();

                            }
                        }
以及了解GPS状态,无论是否启用

boolean isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
以及删除更新的

if(locationManager != null){locationManager.removeUpdates(this);

使用gps,您可以在没有互联网的情况下获取当前位置@officebrain此代码适用于Internet。我需要在没有互联网连接的情况下获取纬度和经度。你可以停止互联网,到户外区域获取当前位置。