Google glass GDK - 获取地理位置(经纬度)

与Android类似,直接贴代码~

1         LocationManager lm = (LocationManager) this.getSystemService(LOCATION_SERVICE);
2         Location location = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
3         double jingdu = location.getLatitude();
4         double weidu  = location.getLongitude();
5         double haiba  = location.getAltitude();
6         System.out.println("经度=" + jingdu + " 纬度=" + weidu + " 海拔=" + haiba);

 最后添加权限:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

 

posted @ 2014-08-05 10:53  一起2  阅读(88)  评论(0编辑  收藏  举报