zoukankan      html  css  js  c++  java
  • 关于 android百度地图 调用 地理位置 经纬度坐标,只调用一次的解决方法,通知栏不总是 搜索 GPS 。。。

    上代码吧。。。

    //读取当前坐标
             final LocationClient mLocationClient = new LocationClient(mActivity);
             mLocationClient.setLocOption(GPSUtil.GetOnceOption());
             mLocationClient.registerLocationListener( new BDLocationListener() {
                    
                    @Override
                    public void onReceiveLocation(BDLocation location) {
                        // TODO Auto-generated method stub
                        if(location!=null){
                            longitude=location.getLongitude();
                            latitude=location.getLatitude();
                        }
    //这里是你取得经纬度后执行的业务逻辑操作
    //....
                        //几秒钟之后自动停止获取gps
                        new Handler().postDelayed(new Runnable() {  
                            @Override  
                            public void run() {  
                                mLocationClient.stop();
    //                            PromptUtil.showLongToast(mActivity, Longitude+"");
                            }  
                  
                        }, 1*1000);  
                    }
                } ); 
                mLocationClient.start();
                if (mLocationClient != null && mLocationClient.isStarted())
                mLocationClient.requestLocation();
  • 相关阅读:
    xt
    UVA 10200 Prime Time (打表)
    CodeForces 540B School Marks
    CodeForces 540C Ice Cave (BFS)
    poj 3250 Bad Hair Day(栈的运用)
    hdu A Magic Lamp
    hdu 4325 Flowers(区间离散化)
    hdu 5500 Reorder the Books
    V2X之标准
    V2X的前生今世
  • 原文地址:https://www.cnblogs.com/duanweishi/p/4605346.html
Copyright © 2011-2022 走看看