i'm developing an augmented reality application by android and i need some information about the location and direction of device from google map in mobile .

我正在开发一个由Android增强现实应用程序,我需要一些关于设备的位置和方向从谷歌地图移动中的信息。

how can i get those information , if there's any tutorial explain that .

如果有任何教程解释,我怎样才能获得这些信息。

1 个解决方案

#1


2

You should use LocationManager and LocationListener classes. Use it like at Google Developers API Guide: create a LocationManager class:

您应该使用LocationManager和LocationListener类。像在Google Developers API指南中一样使用它:创建一个LocationManager类:

LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

Create LocationListener with overriding onLocationChanged() method, that calls every time you change location:

创建LocationListener并覆盖onLocationChanged()方法,每次更改位置时调用:

        // Define a listener that responds to location updates
LocationListener locationListener = new LocationListener() {

        public void onLocationChanged(Location location) {
          // Called when a new location is found by the network location provider.
          makeUseOfNewLocation(location);
        }

        public void onStatusChanged(String provider, int status, Bundle extras) {}

        public void onProviderEnabled(String provider) {}

        public void onProviderDisabled(String provider) {}
      };

Register the LocationListener in LocationManager:

在LocationManager中注册LocationListener:

    // Register the listener with the Location Manager to receive location updates
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);

Notice, onLocationChanged() is called at the first time, when you register it with LocationManager

注意,当您使用LocationManager注册onLocationChanged()时,第一次调用onLocationChanged()

更多相关文章

  1. DialogFragment自定义dialog的位置和大小
  2. android里通过什么什么事件可以拿到由于click后的EditText的光标
  3. 如果服务器位于不同的位置,如何保存客户端机器时间

随机推荐

  1. Android SDK API 15 各安装包下载地址
  2. Android TextView使用权重时文字无法居中
  3. 2.4.12 画廊视图
  4. Android之Animation属性配置文件
  5. ch023 Android ContentProvider(第一部分
  6. Android配置文件中标签
  7. Android单元测试
  8. android全屏显示
  9. Android多点触控
  10. Linux/Android(安卓)多点触摸支持