android之location03

 

android之location03
private class ButtonListener implements OnClickListener
    {
        @Override
        public void onClick(View v) {
            //得到LocationManager对象
            LocationManager locationManager=(LocationManager)MainActivity.this.getSystemService(Context.LOCATION_SERVICE);
            //定义当前所使用的Location Provider
            //第二个参数:隔多少秒更新一次    第三个参数:隔多少距离更新一次
            locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 5000, new TestLocationListener());
        }
    }
    
    class TestLocationListener implements LocationListener
    {
        @Override
        public void onLocationChanged(Location location) {
            System.out.println("onLocationChanged");
            
            System.out.println(location.getLongitude());//获取经度
            System.out.println(location.getLatitude());//获取纬度
        }

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {
            System.out.println("onStatusChanged");
            
        }

        @Override
        public void onProviderEnabled(String provider) {
            System.out.println("onProviderEnabled");
            
        }

        @Override
        public void onProviderDisabled(String provider) {
            System.out.println("onProviderDisabled");
            
        }
        
    }
android之location03

 

android之location03,布布扣,bubuko.com

android之location03

上一篇:安卓中linearLayout下android_layout.weight的属性的详细介绍


下一篇:Android popupwindow 失去焦点或者点击空白区域时消失的解决方法