当前位置: 首页>>代码示例>>Java>>正文


Java BDLocationListener类代码示例

本文整理汇总了Java中com.baidu.location.BDLocationListener的典型用法代码示例。如果您正苦于以下问题:Java BDLocationListener类的具体用法?Java BDLocationListener怎么用?Java BDLocationListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BDLocationListener类属于com.baidu.location包,在下文中一共展示了BDLocationListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: call

import com.baidu.location.BDLocationListener; //导入依赖的package包/类
@Override
public void call(final Subscriber<? super BDLocation> subscriber) {
    BDLocation lateKnownLocation = LocationClient.get(context).getLastKnownLocation();
    if (lateKnownLocation != null) {
        subscriber.onNext(lateKnownLocation);
        subscriber.onCompleted();
    } else {
        BDLocationListener bdLocationListener = new BDLocationListener() {
            @Override
            public void onReceiveLocation(BDLocation bdLocation) {
                subscriber.onNext(bdLocation);
                subscriber.onCompleted();
            }
        };
        LocationClient.get(context).locate(bdLocationListener);
    }
}
 
开发者ID:li-yu,项目名称:FakeWeather,代码行数:18,代码来源:LocationLastKnownOnSubscribe.java

示例2: getCity

import com.baidu.location.BDLocationListener; //导入依赖的package包/类
private void getCity() {
    mListener = new BDLocationListener(){

        @Override
        public void onReceiveLocation(BDLocation location) {
            if (null != location && location.getLocType() != BDLocation.TypeServerError){
                city=location.getCity();
                location_city.setText(location.getCity());
                addess=location.getAddrStr();
                Lat=location.getLatitude();
                Lng=location.getLongitude();
                Log.e("Address", addess);
                Log.e("CCCC",city);
                getDate();
            }

        }
    };


}
 
开发者ID:BeckNiu,项目名称:MyCar,代码行数:22,代码来源:RoadFragment.java

示例3: Getctiy

import com.baidu.location.BDLocationListener; //导入依赖的package包/类
public  static String Getctiy(){
        mListener = new BDLocationListener(){
            @Override
            public void onReceiveLocation(BDLocation location) {
                if (null != location && location.getLocType() != BDLocation.TypeServerError){
                  city=location.getCity();
//                    location_city.setText(location.getCity());
//                    addess=location.getAddrStr();
//                    Lat=location.getLatitude();
//                    Lng=location.getLongitude();
//                    Log.e("Address", addess);
                    Log.e("CCCC",city);
                }

            }
        };


        return city;
    }
 
开发者ID:BeckNiu,项目名称:MyCar,代码行数:21,代码来源:LocaionUtil.java

示例4: onCreate

import com.baidu.location.BDLocationListener; //导入依赖的package包/类
@Override
    public void onCreate(Context context) {
        mLocationClient = new LocationClient(context);
        mLocationClient.registerLocationListener(new BDLocationListener() {
            @Override
            public void onReceiveLocation(BDLocation bdLocation) {
                mLatitude = bdLocation.getLatitude();
                mLontitude = bdLocation.getLongitude();
            }
        });
        LocationClientOption option = new LocationClientOption();
        option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
        option.setCoorType("gcj02");//可选,默认gcj02,设置返回的定位结果坐标系,
        int span = 2000;
        option.setScanSpan(span);//可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的
//        option.setIsNeedAddress(checkGeoLocation.isChecked());//可选,设置是否需要地址信息,默认不需要
        option.setOpenGps(true);//可选,默认false,设置是否使用gps
        option.setLocationNotify(true);//可选,默认false,设置是否当gps有效时按照1S1次频率输出GPS结果
        option.setIgnoreKillProcess(false);//可选,默认true,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop的时候杀死这个进程,默认不杀死
        option.setEnableSimulateGps(false);//可选,默认false,设置是否需要过滤gps仿真结果,默认需要
        mLocationClient.setLocOption(option);
        mLocationClient.start();
        bindService(context);
    }
 
开发者ID:fanwucoder,项目名称:mvpChat,代码行数:25,代码来源:AbsCameraModel.java

示例5: getLocation

import com.baidu.location.BDLocationListener; //导入依赖的package包/类
private String getLocation() {
    mLocationClient = new LocationClient(mContext);
    mLocationClient.registerLocationListener(new BDLocationListener() {
        @Override
        public void onReceiveLocation(BDLocation bdLocation) {
            mLocation = bdLocation.getAddress().address;
            mUserDetailFragView.updateLocation(mLocation);
            mLocationClient.stop();
        }
    });
    LocationClientOption option = new LocationClientOption();
    option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
    option.setCoorType("gcj02");//可选,默认gcj02,设置返回的定位结果坐标系,
    int span = 2000;
    option.setScanSpan(span);//可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的
    option.setIsNeedAddress(true);//可选,设置是否需要地址信息,默认不需要
    option.setOpenGps(true);//可选,默认false,设置是否使用gps
    option.setLocationNotify(true);//可选,默认false,设置是否当gps有效时按照1S1次频率输出GPS结果
    option.setIgnoreKillProcess(false);//可选,默认true,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop的时候杀死这个进程,默认不杀死
    option.setEnableSimulateGps(false);//可选,默认false,设置是否需要过滤gps仿真结果,默认需要
    mLocationClient.setLocOption(option);
    mLocationClient.start();
    return mLocation;
}
 
开发者ID:fanwucoder,项目名称:mvpChat,代码行数:25,代码来源:UserDetailFragPresenterImpl.java

示例6: initData

import com.baidu.location.BDLocationListener; //导入依赖的package包/类
@Override
    public void initData() {
        ButterKnife.bind(this);
        FragmentManager fm = getSupportFragmentManager();
        HomeFragment homeFragment = (HomeFragment) fm.findFragmentById(R.id.fragment_container);
        if (homeFragment == null) {
            homeFragment = HomeFragment.newInstance();
            fm.beginTransaction().add(R.id.fragment_container,homeFragment).commit();
        }

        mHomePresenter = new HomePresenter(homeFragment);
        BDLocationListener myListener = new MyLocationListener();
        MyApplication.getmLocationClient().registerLocationListener(myListener);

//
    }
 
开发者ID:byhieg,项目名称:easyweather,代码行数:17,代码来源:MainActivity.java

示例7: onCreate

import com.baidu.location.BDLocationListener; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // 设置程序标题
    setTitle(R.string.app_title);
    // 设置内容
    setContentView(R.layout.activity_main);
    // umeng统计
    MobclickAgent.updateOnlineConfig(getApplication());
    // 接收用户选择的城市属性
    CityModel city = getIntent().getParcelableExtra("select_city");
    if (city == null) {
        // 定位用户地理位置
        ((MyApplication) getApplication()).registerLocationListener(BDLocationListener);
        ((MyApplication) getApplication()).LocationStart();
    } else {
        showMainActivity(city);
    }

}
 
开发者ID:mylukin,项目名称:geshui,代码行数:21,代码来源:MainActivity.java

示例8: onReceiveLocation

import com.baidu.location.BDLocationListener; //导入依赖的package包/类
@Override
public void onReceiveLocation(BDLocation location) {
    if (location == null)
        return;

    switch (location.getLocType()) {
        // 定位成功
        case BDLocation.TypeGpsLocation:
        case BDLocation.TypeNetWorkLocation:
        case BDLocation.TypeOffLineLocation:
            showMainActivity(Integer.valueOf(location.getCityCode()));
            ((MyApplication) getApplication()).LocationStop();
            ((MyApplication) getApplication()).unRegisterLocationListener(BDLocationListener);
            break;
        // 定位失败
        default:

            break;
    }
}
 
开发者ID:mylukin,项目名称:geshui,代码行数:21,代码来源:MainActivity.java

示例9: watchPosition

import com.baidu.location.BDLocationListener; //导入依赖的package包/类
private boolean watchPosition(JSONObject options, int watchId, final CallbackContext callback) {
  Log.i(TAG, "监听位置变化");
  Context ctx = cordova.getActivity().getApplicationContext();
  PositionOptions positionOpts = new PositionOptions(options);
  BDGeolocation geolocation = new BDGeolocation(ctx);
  store.put(watchId, geolocation);
  return geolocation.watchPosition(positionOpts, new BDLocationListener() {
    @Override
    public void onReceiveLocation(BDLocation location) {
      JSONArray message = new MessageBuilder(location).build();
      PluginResult result = new PluginResult(PluginResult.Status.OK, message);
      result.setKeepCallback(true);
      callback.sendPluginResult(result);
    }
  });
}
 
开发者ID:ETENG-OSP,项目名称:cordova-plugin-baidu-geolocation,代码行数:17,代码来源:GeolocationPlugin.java

示例10: registerListener

import com.baidu.location.BDLocationListener; //导入依赖的package包/类
/***
 * 
 * @param listener
 * @return
 */

public boolean registerListener(BDLocationListener listener){
	boolean isSuccess = false;
	if(listener != null){
		client.registerLocationListener(listener);
		isSuccess = true;
	}
	return  isSuccess;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:15,代码来源:LocationService.java

示例11: locate

import com.baidu.location.BDLocationListener; //导入依赖的package包/类
public void locate(final BDLocationListener bdLocationListener) {
    final BDLocationListener realListener = new BDLocationListener() {
        @Override
        public void onReceiveLocation(BDLocation bdLocation) {
            bdLocationListener.onReceiveLocation(bdLocation);
            //防止内存溢出
            realClient.unRegisterLocationListener(this);
            stop();
        }
    };
    realClient.registerLocationListener(realListener);
    if (!realClient.isStarted()) {
        realClient.start();
    }
}
 
开发者ID:li-yu,项目名称:FakeWeather,代码行数:16,代码来源:LocationClient.java

示例12: call

import com.baidu.location.BDLocationListener; //导入依赖的package包/类
@Override
public void call(final Subscriber<? super BDLocation> subscriber) {
    BDLocationListener bdLocationListener = new BDLocationListener() {
        @Override
        public void onReceiveLocation(BDLocation bdLocation) {
            subscriber.onNext(bdLocation);
            subscriber.onCompleted();
        }
    };
    LocationClient.get(context).locate(bdLocationListener);
}
 
开发者ID:li-yu,项目名称:FakeWeather,代码行数:12,代码来源:LocationOnSubscribe.java

示例13: registerListener

import com.baidu.location.BDLocationListener; //导入依赖的package包/类
/***
 *
 * @param listener
 * @return
 */

public boolean registerListener(BDLocationListener listener){
    boolean isSuccess = false;
    if(listener != null){
        client.registerLocationListener(listener);
        isSuccess = true;
    }
    return  isSuccess;
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:15,代码来源:LocationService.java

示例14: registerLocationListener

import com.baidu.location.BDLocationListener; //导入依赖的package包/类
public boolean registerLocationListener(BDLocationListener listener){
    boolean isSuccess = false;
    if(listener != null){
        mClient.registerLocationListener(listener);
        isSuccess = true;
    }
    return  isSuccess;
}
 
开发者ID:yangjiantao,项目名称:AndroidLocationLib,代码行数:9,代码来源:BDLocationService.java

示例15: requestLocation

import com.baidu.location.BDLocationListener; //导入依赖的package包/类
public void requestLocation(final LocationResultListener listener, final int retry) {
    locationClient.start();
    locationClient.registerLocationListener(new BDLocationListener() {
        @Override
        public void onReceiveLocation(BDLocation bdLocation) {
            locationClient.unRegisterLocationListener(this);
            String city = bdLocation.getCity();
            boolean success = true;
            if (TextUtils.isEmpty(city)) {
                city = null;
                success = false;
                if (retry < 3) {
                    Log.e("LocationProvider", "request location failure retry " + retry + " times");
                    requestLocation(listener, retry + 1);
                    return;
                }
            } else {
                // 大多数情况下,将"广州市"直接显示成"广州"
                city = city.replaceFirst("市.*$", "");
            }
            locationClient.stop();
            listener.onLocationResult(success, city, bdLocation.getCity() + bdLocation.getDistrict(), bdLocation.getLatitude(), bdLocation.getLongitude());
        }
    });
    // 0:正常发起了定位。
    // 1:服务没有启动。
    // 2:没有监听函数。
    // 6:请求间隔过短。 前后两次请求定位时间间隔不能小于1000ms。
    int code = locationClient.requestLocation();
    if (code == 6) {
        locationClient.requestOfflineLocation();
    }
}
 
开发者ID:huang303513,项目名称:Coding-Android,代码行数:34,代码来源:LocationProvider.java


注:本文中的com.baidu.location.BDLocationListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。