gps定位
来源:互联网 发布:美工钢笔价格 编辑:程序博客网 时间:2024/04/30 19:46
private void getLocation() {// 获取位置管理服务String serviceName = Context.LOCATION_SERVICE;locationManager = (LocationManager) this.getSystemService(serviceName);// 查找到服务信息Criteria criteria = new Criteria();criteria.setAccuracy(Criteria.ACCURACY_FINE); // 高精度criteria.setAltitudeRequired(false);criteria.setBearingRequired(false);criteria.setCostAllowed(true);criteria.setPowerRequirement(Criteria.POWER_LOW); // 低功耗provider = locationManager.getBestProvider(criteria, true); // 获取GPS信息orientation();listener = new LocationListener() {@Overridepublic void onStatusChanged(String provider, int status, Bundle extras) {}@Overridepublic void onProviderEnabled(String provider) {}@Overridepublic void onProviderDisabled(String provider) {}@Overridepublic void onLocationChanged(Location location) {}};locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100 * 1000, 500, listener);}
private void orientation() {new Thread(new Runnable() {@Overridepublic void run() {while (truevalue == true) {try {Thread.sleep(1500);} catch (InterruptedException e) {e.printStackTrace();}location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); // 通过GPS获取位置Message message = new Message();if (location == null) {message.what = 1;} else {message.what = 0;}hand.sendMessage(message);}}}).start();}Handler hand = new Handler() {@Overridepublic void handleMessage(Message msg) {super.handleMessage(msg);if (msg.what == 1) {//show("gps无法定位");} }};
latitude = location.getLatitude();longitude = location.getLongitude();
0 0
- GPS定位
- GPS定位
- GPS定位
- GPS定位
- GPS定位
- gps定位
- GPS定位
- GPS定位
- GPS定位
- gps定位
- gps定位
- GPS定位
- GPS定位+经纬度定位
- GPS定位功能。GPS定位例子
- GPS定位原理
- GPS定位原理概述
- GPS车载定位系统
- GPS全球卫星定位导航系统
- 秋高气爽的秋日,我们一行7人的牡丹江恒丰纸业股份公司的信息化应用考察学习(图文)
- Java enum的用法详解
- 7年一次机会,能把握住吗?既不活在当下,也不活在未来,仿佛从未活过
- android的byte转int
- JSTL(必会使用)
- gps定位
- 高中时代
- [Tips]在 MacOS 中将 mysql 添加到环境变量
- STL源码剖析——散列表hashtable
- XAMPP在Linux中安装
- CalTech machine learning video 8 note(Bias-Variance Tradeoff)
- linux: 几个常用makefile模板
- Android L下用XXRadius设置圆角背景图片不能显示
- feathers组件记录