在Android应用程序使用GPS [英] Using GPS in android application

查看:129
本文介绍了在Android应用程序使用GPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前的工作在Android应用程序使用GPS。在Android的文档,我看到下面的行

I am currently working on using GPS in android application. In android docs I saw the following line

LocationProvider locationProvider = LocationManager.NETWORK_PROVIDER; 

// Or, use GPS location data: 

// LocationProvider locationProvider = LocationManager.GPS_PROVIDER; 

locationManager.requestLocationUpdates(locationProvider, 0, 0, locationListener);

但LocationProvider是一个抽象类怎么来的,我们实例化LocationProvider,也
第一行返回一个String对象locationProvider。任何人都可以清楚我怀疑是否
文件错误或这涉及到一些其他的解释

but LocationProvider is an abstract class how come we instantiate LocationProvider, also the first line returns a String to the object locationProvider. Can anyone clear my doubt whether document is wrong or this involves some other explanation

推荐答案

由于似乎没有人来回答你问什么,每个人似乎都被抛如何得到我,都会造成干扰的位置的答案。

Since nobody seems to answer what you are asking, and everybody seems to be throwing answers about how to get the location I will interfere.

我有,当我看到的文档,你有同样的问题。下面几行:

I had the same question you had when I saw the documentation. The following line:

LocationProvider locationProvider = LocationManager.NETWORK_PROVIDER;

也许打算是:

LocationProvider locationProvider = locationManager.getProvider(LocationManager.NETWORK_PROVIDER);

由于LocationProvider是一个抽象类,这意味着你已经收到sublcases locationProvider一个类的实例,因此,你保证能够调用在LocationProvider文档中定义的方法。

Since LocationProvider is an abstract class, this means you have received an instance of a class that sublcases locationProvider, hence you are guaranteed to be able to call the methods defined in the LocationProvider docs.

所以,这只是一些没有写prop​​perly,或者intented避免复制和放大器;贴节目。

So, it was just something that was not propperly written, or perhaps intented to avoid copy & paste programming.

这篇关于在Android应用程序使用GPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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