Java 如何在不使用互联网的情况下使用GPS接收机?
我计划使用支持GPS的Android手机创建一个不会使用互联网访问用户当前位置的应用程序 我需要知道的是如何在Eclipse中编写代码。您能否共享一段Java代码,该代码将返回GPS用户的经度和纬度,而无需访问internetJava 如何在不使用互联网的情况下使用GPS接收机?,java,android,eclipse,gps,Java,Android,Eclipse,Gps,我计划使用支持GPS的Android手机创建一个不会使用互联网访问用户当前位置的应用程序 我需要知道的是如何在Eclipse中编写代码。您能否共享一段Java代码,该代码将返回GPS用户的经度和纬度,而无需访问internet 此外,是否可以使其不访问手机网络-直接从卫星获取用户位置?在应用程序标签上方的Android清单中添加以下行: <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
此外,是否可以使其不访问手机网络-直接从卫星获取用户位置?在应用程序标签上方的Android清单中添加以下行:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
编辑:当您调用LocationManager LocationManager=(LocationManager)this.getSystemService(Context.LOCATION\u服务)时;
locationManager.RequestLocationUpdate(locationManager.GPS\u提供程序,0,0,新LocationListener()…
这将设置一个新的LocationListener来侦听GPS。第一个数字表示每次检查之间的最小毫秒数(注意,这只是一个指示器,系统可能会更频繁/更少地检查),第二个数字表示每次检查之间的最小行驶距离(以米为单位)。因此,如果两者都为0,则将不断检查GPS,并在新值可用时立即将其发送到onLocationChanged()
有关更多详细信息,请参见GPS纯粹是一个接收器;不涉及双向通信。另外,请阅读以下内容:。检查此项:您需要先显示您的努力。tnx获得答案。我应该使用什么功能启用从卫星进行的实时跟踪?谢谢我在回答中添加了更多som互联网问题在哪里
LocationManager locationManager = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener() {
onLocationChanged(Location location) {
// put code in here to respond to a change in location
}
onProviderDisabled(String provider) {
// put code in here to respond to GPS being disabled
}
onProviderEnabled(String provider) {
// put code in here to respond to GPS being enabled
}
onStatusChanged(String provider, int status, Bundle extras) {
// put code in here to respond to change in GPS status (e.g. GPS becomes unavailable)
}
});