Java Code Examples for com.baidu.location.BDLocation#TypeCriteriaException
The following examples show how to use
com.baidu.location.BDLocation#TypeCriteriaException .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WBNearbyActivity.java From Simpler with Apache License 2.0 | 6 votes |
@Override public void onReceiveLocation(BDLocation location) { // 在回调方法运行在remote进程 // 获取定位类型 int locType = location.getLocType(); if (locType == BDLocation.TypeGpsLocation || locType == BDLocation.TypeNetWorkLocation || locType == BDLocation.TypeOffLineLocation) { // 定位成功。GPS定位结果 || 网络定位结果 || 离线定位结果 // 纬度 mLatitude = String.valueOf(location.getLatitude()); // 经度 mLongitude = String.valueOf(location.getLongitude()); mHandler.sendEmptyMessage(HANDLE_ADDRESS_OK); } else if (location.getLocType() == BDLocation.TypeServerError) { mHandler.sendEmptyMessage(HANDLE_SERVER_ERROR); } else if (location.getLocType() == BDLocation.TypeNetWorkException) { mHandler.sendEmptyMessage(HANDLE_NETWORK_EXCEPTION); } else if (location.getLocType() == BDLocation.TypeCriteriaException) { mHandler.sendEmptyMessage(HANDLE_CRITERIA_EXCEPTION); } }
Example 2
Source File: WBPostActivity.java From Simpler with Apache License 2.0 | 6 votes |
@Override public void onReceiveLocation(BDLocation location) { // 在回调方法运行在remote进程 // 获取定位类型 int locType = location.getLocType(); if (locType == BDLocation.TypeGpsLocation || locType == BDLocation.TypeNetWorkLocation || locType == BDLocation.TypeOffLineLocation) { // 定位成功。GPS定位结果 || 网络定位结果 || 离线定位结果 // 纬度 mLatitude = location.getLatitude(); // 经度 mLongitude = location.getLongitude(); // 获取地址信息 mAddrStr = location.getAddrStr(); mHandler.sendEmptyMessage(HANDLE_ADDRESS_OK); } else if (location.getLocType() == BDLocation.TypeServerError) { mHandler.sendEmptyMessage(HANDLE_SERVER_ERROR); } else if (location.getLocType() == BDLocation.TypeNetWorkException) { mHandler.sendEmptyMessage(HANDLE_NETWORK_EXCEPTION); } else if (location.getLocType() == BDLocation.TypeCriteriaException) { mHandler.sendEmptyMessage(HANDLE_CRITERIA_EXCEPTION); } }
Example 3
Source File: BaiduUtils.java From LocationProvider with Apache License 2.0 | 6 votes |
/** * 判断位置是否可用 * * @param bdLocation * @return */ public static final boolean isValidLocation(BDLocation bdLocation, BDLocation cashLocation) { boolean isValid = false; if (bdLocation.getLocType() == BDLocation.TypeGpsLocation) { // 当前为GPS定位结果 isValid = true; } else if (bdLocation.getLocType() == BDLocation.TypeNetWorkLocation) { // 当前为网络定位结果 if (cashLocation == null || !cashLocation.getTime().equals(bdLocation.getTime())) isValid = true; } else if (bdLocation.getLocType() == BDLocation.TypeOffLineLocation) { // 当前为离线定位结果 } else if (bdLocation.getLocType() == BDLocation.TypeServerError) { // 当前网络定位失败 // 可将定位唯一ID、IMEI、定位失败时间反馈至[email protected] } else if (bdLocation.getLocType() == BDLocation.TypeNetWorkException) { // 当前网络不通 } else if (bdLocation.getLocType() == BDLocation.TypeCriteriaException) { // 当前缺少定位依据,可能是用户没有授权,建议弹出提示框让用户开启权限 // 可进一步参考onLocDiagnosticMessage中的错误返回码 } return isValid; }
Example 4
Source File: MyLocationListener.java From easyweather with MIT License | 6 votes |
@Override public void onReceiveLocation(final BDLocation location) { String city = location.getCity(); if (city != null) { final String name = city.substring(0, city.length() - 1); EventBus.getDefault().post(new CityNameMessage(name)); } else if (location.getLocType() == BDLocation.TypeNetWorkException) { Toast.makeText(MyApplication.getAppContext(), "网络不同导致定位失败,请检查网络是否通畅", Toast.LENGTH_LONG).show(); } else if (location.getLocType() == BDLocation.TypeCriteriaException) { Toast.makeText(MyApplication.getAppContext(), "无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机", Toast.LENGTH_LONG).show(); } MyApplication.getmLocationClient().stop(); }
Example 5
Source File: MainActivity.java From RxLocation with Apache License 2.0 | 4 votes |
private void receiveBaiduLocation(BDLocation location) { //copy from baidu location demo. if (null != location && location.getLocType() != BDLocation.TypeServerError) { StringBuffer sb = new StringBuffer(256); sb.append("time : "); location.getCountryCode(); /** * 时间也可以使用systemClock.elapsedRealtime()方法 获取的是自从开机以来,每次回调的时间; * location.getTime() 是指服务端出本次结果的时间,如果位置不发生变化,则时间不变 */ sb.append(location.getTime()); sb.append("\nlocType : ");// 定位类型 sb.append(location.getLocType()); sb.append("\nlocType description : ");// *****对应的定位类型说明***** sb.append(location.getLocTypeDescription()); sb.append("\nlatitude : ");// 纬度 sb.append(location.getLatitude()); sb.append("\nlontitude : ");// 经度 sb.append(location.getLongitude()); sb.append("\nradius : ");// 半径 sb.append(location.getRadius()); sb.append("\nCountryCode : ");// 国家码 sb.append(location.getCountryCode()); sb.append("\nCountry : ");// 国家名称 sb.append(location.getCountry()); sb.append("\ncitycode : ");// 城市编码 sb.append(location.getCityCode()); sb.append("\ncity : ");// 城市 sb.append(location.getCity()); sb.append("\nDistrict : ");// 区 sb.append(location.getDistrict()); sb.append("\nStreet : ");// 街道 sb.append(location.getStreet()); sb.append("\naddr : ");// 地址信息 sb.append(location.getAddrStr()); sb.append("\nUserIndoorState: ");// *****返回用户室内外判断结果***** sb.append(location.getUserIndoorState()); sb.append("\nDirection(not all devices have value): "); sb.append(location.getDirection());// 方向 sb.append("\nlocationdescribe: "); sb.append(location.getLocationDescribe());// 位置语义化信息 sb.append("\nPoi: ");// POI信息 if (location.getPoiList() != null && !location.getPoiList().isEmpty()) { for (int i = 0; i < location.getPoiList().size(); i++) { Poi poi = (Poi) location.getPoiList().get(i); sb.append(poi.getName() + ";"); } } if (location.getLocType() == BDLocation.TypeGpsLocation) {// GPS定位结果 sb.append("\nspeed : "); sb.append(location.getSpeed());// 速度 单位:km/h sb.append("\nsatellite : "); sb.append(location.getSatelliteNumber());// 卫星数目 sb.append("\nheight : "); sb.append(location.getAltitude());// 海拔高度 单位:米 sb.append("\ngps status : "); sb.append(location.getGpsAccuracyStatus());// *****gps质量判断***** sb.append("\ndescribe : "); sb.append("gps定位成功"); } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {// 网络定位结果 // 运营商信息 if (location.hasAltitude()) {// *****如果有海拔高度***** sb.append("\nheight : "); sb.append(location.getAltitude());// 单位:米 } sb.append("\noperationers : ");// 运营商信息 sb.append(location.getOperators()); sb.append("\ndescribe : "); sb.append("网络定位成功"); } else if (location.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果 sb.append("\ndescribe : "); sb.append("离线定位成功,离线定位结果也是有效的"); } else if (location.getLocType() == BDLocation.TypeServerError) { sb.append("\ndescribe : "); sb.append("服务端网络定位失败,可以反馈IMEI号和大体定位时间到[email protected],会有人追查原因"); } else if (location.getLocType() == BDLocation.TypeNetWorkException) { sb.append("\ndescribe : "); sb.append("网络不同导致定位失败,请检查网络是否通畅"); } else if (location.getLocType() == BDLocation.TypeCriteriaException) { sb.append("\ndescribe : "); sb.append("无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机"); } mLocation.setText(sb.toString()); } }
Example 6
Source File: BDLocationService.java From Social with Apache License 2.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { Log.d("BaiduMapTestActivity", "error code : " + location.getLocType()); //navigateTo(location); //Receive Location StringBuffer sb = new StringBuffer(256); StringBuffer sb_points = new StringBuffer(); sb.append("time : "); sb.append(location.getTime()); sb.append("\nerror code : "); sb.append(location.getLocType()); sb.append("\nlatitude : "); sb.append(location.getLatitude()); sb.append("\nlontitude : "); sb.append(location.getLongitude()); sb.append("\nradius : "); sb.append(location.getRadius()); SharedPreferenceUtil.setLocation(String.valueOf(location.getLongitude()), String.valueOf(location.getLatitude()), "未知", "未知"); Log.d("location", sb.toString()); if (location.getLocType() == BDLocation.TypeGpsLocation) {// GPS定位结果 sb.append("\nspeed : "); sb.append(location.getSpeed());// 单位:公里每小时 sb.append("\nsatellite : "); sb.append(location.getSatelliteNumber()); sb.append("\nheight : "); sb.append(location.getAltitude());// 单位:米 sb.append("\ndirection : "); sb.append(location.getDirection());// 单位度 sb.append("\naddr : "); sb.append(location.getAddrStr()); sb.append("\ndescribe : "); sb.append("gps定位成功"); SharedPreferenceUtil.setLocation(String.valueOf(location.getLongitude()), String.valueOf(location.getLatitude()), String.valueOf(location.getCity())+String.valueOf(location.getDistrict()),location.getAddrStr()); Log.d("location", sb.toString()); //Toast.makeText(SocialMainActivity.this, sb.toString(), Toast.LENGTH_LONG).show(); } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {// 网络定位结果 sb.append("\naddr : "); sb.append(location.getAddrStr()); //运营商信息 sb.append("\noperationers : "); sb.append(location.getOperators()); sb.append("\ndescribe : "); sb.append("网络定位成功"); //保存位置 SharedPreferenceUtil.setLocation(String.valueOf(location.getLongitude()), String.valueOf(location.getLatitude()), String.valueOf(location.getCity())+String.valueOf(location.getDistrict()),location.getAddrStr()); //Toast.makeText(MyApplication.mContext, sb.toString(),Toast.LENGTH_LONG).show(); Log.d("SocialMainActivity", sb.toString()); } else if (location.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果 sb.append("\ndescribe : "); sb.append("离线定位成功,离线定位结果也是有效的"); //Toast.makeText(MyApplication.mContext, sb.toString(), Toast.LENGTH_LONG).show(); } else if (location.getLocType() == BDLocation.TypeServerError) { sb.append("\ndescribe : "); sb.append("服务端网络定位失败,可以反馈IMEI号和大体定位时间到[email protected],会有人追查原因"); //Toast.makeText(MyApplication.mContext, sb.toString(),Toast.LENGTH_LONG).show(); } else if (location.getLocType() == BDLocation.TypeNetWorkException) { sb.append("\ndescribe : "); sb.append("网络不同导致定位失败,请检查网络是否通畅"); //Toast.makeText(MyApplication.mContext, sb.toString(),Toast.LENGTH_LONG).show(); } else if (location.getLocType() == BDLocation.TypeCriteriaException) { sb.append("\ndescribe : "); sb.append("无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机"); //Toast.makeText(MyApplication.mContext, sb.toString(),Toast.LENGTH_LONG).show(); } sb.append("\nlocationdescribe : "); sb.append(location.getLocationDescribe());// 位置语义化信息 List<Poi> list = location.getPoiList();// POI数据 if (list != null) { sb.append("\npoilist size = : "); sb.append(list.size()); for (Poi p : list) { sb.append("\npoi= : "); sb.append(p.getId() + " " + p.getName() + " " + p.getRank()); sb_points.append(p.getName()+"_"); } SharedPreferenceUtil.setPoints(sb_points.toString()); } Log.i("location", sb.toString()); SharedPreferenceUtil.setLocation(String.valueOf(location.getLongitude()), String.valueOf(location.getLatitude()), String.valueOf(location.getCity()) + String.valueOf(location.getDistrict()), location.getAddrStr()); //定位成功------------------------------------------------------------------------------ //OkhttpUtil.pollServive(new Handler()); }
Example 7
Source File: WelcomeActivity.java From Social with Apache License 2.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { Log.d("BaiduMapTestActivity", "error code : " + location.getLocType()); //navigateTo(location); //Receive Location StringBuffer sb = new StringBuffer(256); StringBuffer sb_points = new StringBuffer(); sb.append("time : "); sb.append(location.getTime()); sb.append("\nerror code : "); sb.append(location.getLocType()); sb.append("\nlatitude : "); sb.append(location.getLatitude()); sb.append("\nlontitude : "); sb.append(location.getLongitude()); sb.append("\nradius : "); sb.append(location.getRadius()); SharedPreferenceUtil.setLocation(String.valueOf(location.getLongitude()), String.valueOf(location.getLatitude()), "未知", "未知"); Log.d("SocialMainActivity", sb.toString()); if (location.getLocType() == BDLocation.TypeGpsLocation) {// GPS定位结果 sb.append("\nspeed : "); sb.append(location.getSpeed());// 单位:公里每小时 sb.append("\nsatellite : "); sb.append(location.getSatelliteNumber()); sb.append("\nheight : "); sb.append(location.getAltitude());// 单位:米 sb.append("\ndirection : "); sb.append(location.getDirection());// 单位度 sb.append("\naddr : "); sb.append(location.getAddrStr()); sb.append("\ndescribe : "); sb.append("gps定位成功"); SharedPreferenceUtil.setLocation(String.valueOf(location.getLongitude()), String.valueOf(location.getLatitude()), String.valueOf(location.getCity())+String.valueOf(location.getDistrict()),location.getAddrStr()); Log.d("SocialMainActivity", sb.toString()); //Toast.makeText(SocialMainActivity.this, sb.toString(), Toast.LENGTH_LONG).show(); } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {// 网络定位结果 sb.append("\naddr : "); sb.append(location.getAddrStr()); //运营商信息 sb.append("\noperationers : "); sb.append(location.getOperators()); sb.append("\ndescribe : "); sb.append("网络定位成功"); //保存位置 SharedPreferenceUtil.setLocation(String.valueOf(location.getLongitude()), String.valueOf(location.getLatitude()), String.valueOf(location.getCity())+String.valueOf(location.getDistrict()),location.getAddrStr()); //Toast.makeText(WelcomeActivity.this, sb.toString(),Toast.LENGTH_LONG).show(); Log.d("SocialMainActivity", sb.toString()); } else if (location.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果 sb.append("\ndescribe : "); sb.append("离线定位成功,离线定位结果也是有效的"); //Toast.makeText(WelcomeActivity.this, sb.toString(), Toast.LENGTH_LONG).show(); } else if (location.getLocType() == BDLocation.TypeServerError) { sb.append("\ndescribe : "); sb.append("服务端网络定位失败,可以反馈IMEI号和大体定位时间到[email protected],会有人追查原因"); //Toast.makeText(WelcomeActivity.this, sb.toString(),Toast.LENGTH_LONG).show(); } else if (location.getLocType() == BDLocation.TypeNetWorkException) { sb.append("\ndescribe : "); sb.append("网络不同导致定位失败,请检查网络是否通畅"); //Toast.makeText(WelcomeActivity.this, sb.toString(),Toast.LENGTH_LONG).show(); } else if (location.getLocType() == BDLocation.TypeCriteriaException) { sb.append("\ndescribe : "); sb.append("无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机"); //Toast.makeText(WelcomeActivity.this, sb.toString(),Toast.LENGTH_LONG).show(); } sb.append("\nlocationdescribe : "); sb.append(location.getLocationDescribe());// 位置语义化信息 List<Poi> list = location.getPoiList();// POI数据 if (list != null) { sb.append("\npoilist size = : "); sb.append(list.size()); for (Poi p : list) { sb.append("\npoi= : "); sb.append(p.getId() + " " + p.getName() + " " + p.getRank()); sb_points.append(p.getName()+"_"); } SharedPreferenceUtil.setPoints(sb_points.toString()); } Log.i("BaiduLocationApiDem", sb.toString()); SharedPreferenceUtil.setLocation(String.valueOf(location.getLongitude()), String.valueOf(location.getLatitude()), String.valueOf(location.getCity()) + String.valueOf(location.getDistrict()), location.getAddrStr()); //OkhttpUtil.pollServive(handler); //Toast.makeText(WelcomeActivity.this,"SharedPreferenceUtil.getAddress() = " + SharedPreferenceUtil.getAddress(), Toast.LENGTH_LONG).show(); Log.d("location", "address = " + SharedPreferenceUtil.getAddress()); //定位成功------------------------------------------------------------------------------ }
Example 8
Source File: MainActivity.java From LocationProvider with Apache License 2.0 | 4 votes |
private void displayLocation(HooweLocation location, TextView textView) { StringBuffer sb = new StringBuffer(256); sb.append("time : "); /** * 时间也可以使用systemClock.elapsedRealtime()方法 获取的是自从开机以来,每次回调的时间; * location.getTime() 是指服务端出本次结果的时间,如果位置不发生变化,则时间不变 */ sb.append(location.getLocTime()); sb.append("\nlocType : ");// 定位类型 sb.append(location.getLocType()); sb.append("\nlocType description : ");// *****对应的定位类型说明***** sb.append(location.getLocationDescribe()); sb.append("\nlatitude : ");// 纬度 sb.append(location.getLatitude()); sb.append("\nlontitude : ");// 经度 sb.append(location.getLongitude()); // sb.append("\nradius : ");// 半径 // sb.append(location.getRadius()); // sb.append("\nCountryCode : ");// 国家码 // sb.append(location.getCountryCode()); sb.append("\nCountry : ");// 国家名称 sb.append(location.getCountry()); // sb.append("\ncitycode : ");// 城市编码 // sb.append(location.getCityCode()); sb.append("\ncity : ");// 城市 sb.append(location.getCity()); // sb.append("\nDistrict : ");// 区 // sb.append(location.getDistrict()); // sb.append("\nStreet : ");// 街道 // sb.append(location.getStreet()); sb.append("\naddr : ");// 地址信息 sb.append(location.getAddrStr()); // sb.append("\nUserIndoorState: ");// *****返回用户室内外判断结果***** // sb.append(location.getUserIndoorState()); sb.append("\nDirection(not all devices have value): "); sb.append(location.getDirection());// 方向 sb.append("\nlocationdescribe: "); sb.append(location.getLocationDescribe());// 位置语义化信息 // sb.append("\nPoi: ");// POI信息 // if (location.getPoiList() != null && !location.getPoiList().isEmpty()) { // for (int i = 0; i < location.getPoiList().size(); i++) { // Poi poi = (Poi) location.getPoiList().get(i); // sb.append(poi.getName() + ";"); // } // } if (location.getLocType() == BDLocation.TypeGpsLocation) {// GPS定位结果 sb.append("\nspeed : "); sb.append(location.getSpeed());// 速度 单位:km/h sb.append("\nsatellite : "); sb.append(location.getSatelliteNumber());// 卫星数目 // sb.append("\nheight : "); // sb.append(location.getAltitude());// 海拔高度 单位:米 // sb.append("\ngps status : "); // sb.append(location.getGpsAccuracyStatus());// *****gps质量判断***** sb.append("\ndescribe : "); sb.append("gps定位成功"); } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {// 网络定位结果 // 运营商信息 // if (location.hasAltitude()) {// *****如果有海拔高度***** // sb.append("\nheight : "); // sb.append(location.getAltitude());// 单位:米 // } sb.append("\noperationers : ");// 运营商信息 sb.append(location.getOperators()); sb.append("\ndescribe : "); sb.append("网络定位成功"); } else if (location.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果 sb.append("\ndescribe : "); sb.append("离线定位成功,离线定位结果也是有效的"); } else if (location.getLocType() == BDLocation.TypeServerError) { sb.append("\ndescribe : "); sb.append("服务端网络定位失败,可以反馈IMEI号和大体定位时间到[email protected],会有人追查原因"); } else if (location.getLocType() == BDLocation.TypeNetWorkException) { sb.append("\ndescribe : "); sb.append("网络不同导致定位失败,请检查网络是否通畅"); } else if (location.getLocType() == BDLocation.TypeCriteriaException) { sb.append("\ndescribe : "); sb.append("无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机"); } logMsg(sb.toString(), textView); }
Example 9
Source File: LocationUtils.java From LocationProvider with Apache License 2.0 | 4 votes |
private static StringBuffer analysisLocation(HooweLocation location) { StringBuffer sb = new StringBuffer(256); sb.append("time : "); /** * 时间也可以使用systemClock.elapsedRealtime()方法 获取的是自从开机以来,每次回调的时间; * location.getTime() 是指服务端出本次结果的时间,如果位置不发生变化,则时间不变 */ sb.append(location.getLocTime()); sb.append("\nlocType : ");// 定位类型 sb.append(location.getLocType()); sb.append("\nlocType description : ");// *****对应的定位类型说明***** sb.append(location.getLocationDescribe()); sb.append("\nlatitude : ");// 纬度 sb.append(location.getLatitude()); sb.append("\nlontitude : ");// 经度 sb.append(location.getLongitude()); sb.append("\nradius : ");// 半径 sb.append(location.getRadius()); sb.append("\nCountryCode : ");// 国家码 sb.append(location.getCountryCode()); sb.append("\nCountry : ");// 国家名称 sb.append(location.getCountry()); sb.append("\ncitycode : ");// 城市编码 sb.append(location.getCityCode()); sb.append("\ncity : ");// 城市 sb.append(location.getCity()); sb.append("\nDistrict : ");// 区 sb.append(location.getDistrict()); sb.append("\nStreet : ");// 街道 sb.append(location.getStreet()); sb.append("\naddr : ");// 地址信息 sb.append(location.getAddrStr()); sb.append("\nDirection(not all devices have value): "); sb.append(location.getDirection());// 方向 sb.append("\nlocationdescribe: "); sb.append(location.getLocationDescribe());// 位置语义化信息 if (location.getLocType() == BDLocation.TypeGpsLocation) {// GPS定位结果 sb.append("\nspeed : "); sb.append(location.getSpeed());// 速度 单位:km/h sb.append("\nsatellite : "); sb.append(location.getSatelliteNumber());// 卫星数目 sb.append("\nheight : "); sb.append(location.getAltitude());// 海拔高度 单位:米 sb.append("\ndescribe : "); sb.append("gps定位成功"); } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {// 网络定位结果 // 运营商信息 sb.append("\noperationers : ");// 运营商信息 sb.append(location.getOperators()); sb.append("\ndescribe : "); sb.append("网络定位成功"); } else if (location.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果 sb.append("\ndescribe : "); sb.append("离线定位成功,离线定位结果也是有效的"); } else if (location.getLocType() == BDLocation.TypeServerError) { sb.append("\ndescribe : "); sb.append("服务端网络定位失败,可以反馈IMEI号和大体定位时间到[email protected],会有人追查原因"); } else if (location.getLocType() == BDLocation.TypeNetWorkException) { sb.append("\ndescribe : "); sb.append("网络不同导致定位失败,请检查网络是否通畅"); } else if (location.getLocType() == BDLocation.TypeCriteriaException) { sb.append("\ndescribe : "); sb.append("无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机"); } return sb; }
Example 10
Source File: MyLocationListener.java From AndroidAnimationExercise with Apache License 2.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { //Receive Location StringBuffer sb = new StringBuffer(256); sb.append("time : "); sb.append(location.getTime()); sb.append("\nerror code : "); sb.append(location.getLocType()); sb.append("\nlatitude : "); sb.append(location.getLatitude()); sb.append("\nlontitude : "); sb.append(location.getLongitude()); sb.append("\nradius : "); sb.append(location.getRadius()); if (location.getLocType() == BDLocation.TypeGpsLocation) {// GPS定位结果 sb.append("\nspeed : "); sb.append(location.getSpeed());// 单位:公里每小时 sb.append("\nsatellite : "); sb.append(location.getSatelliteNumber()); sb.append("\nheight : "); sb.append(location.getAltitude());// 单位:米 sb.append("\ndirection : "); sb.append(location.getDirection());// 单位度 sb.append("\naddr : "); sb.append(location.getAddrStr()); sb.append("\ndescribe : "); sb.append("gps定位成功"); } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {// 网络定位结果 sb.append("\naddr : "); sb.append(location.getAddrStr()); //运营商信息 sb.append("\noperationers : "); sb.append(location.getOperators()); sb.append("\ndescribe : "); sb.append("网络定位成功"); } else if (location.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果 sb.append("\ndescribe : "); sb.append("离线定位成功,离线定位结果也是有效的"); } else if (location.getLocType() == BDLocation.TypeServerError) { sb.append("\ndescribe : "); sb.append("服务端网络定位失败,可以反馈IMEI号和大体定位时间到[email protected],会有人追查原因"); } else if (location.getLocType() == BDLocation.TypeNetWorkException) { sb.append("\ndescribe : "); sb.append("网络不同导致定位失败,请检查网络是否通畅"); } else if (location.getLocType() == BDLocation.TypeCriteriaException) { sb.append("\ndescribe : "); sb.append("无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机"); } sb.append("\nlocationdescribe : "); sb.append(location.getLocationDescribe());// 位置语义化信息 List<Poi> list = location.getPoiList();// POI数据 if (list != null) { sb.append("\npoilist size = : "); sb.append(list.size()); for (Poi p : list) { sb.append("\npoi= : "); sb.append(p.getId() + " " + p.getName() + " " + p.getRank()); } } Log.e("BaiduLocationApiDem", sb.toString()); }
Example 11
Source File: LocationFragment.java From foodie-app with Apache License 2.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { mLocation = location.getAddrStr(); PrefUtils.set("user", "location", mLocation, getActivity().getBaseContext()); //Receive Location StringBuffer sb = new StringBuffer(256); sb.append("time : "); sb.append(location.getTime()); sb.append("\nerror code : "); sb.append(location.getLocType()); sb.append("\nlatitude : "); sb.append(location.getLatitude()); sb.append("\nlontitude : "); sb.append(location.getLongitude()); sb.append("\nradius : "); sb.append(location.getRadius()); if (location.getLocType() == BDLocation.TypeGpsLocation) {// GPS定位结果 sb.append("\nspeed : "); sb.append(location.getSpeed());// 单位:公里每小时 sb.append("\nsatellite : "); sb.append(location.getSatelliteNumber()); sb.append("\nheight : "); sb.append(location.getAltitude());// 单位:米 sb.append("\ndirection : "); sb.append(location.getDirection());// 单位度 sb.append("\naddr : "); sb.append(location.getAddrStr()); sb.append("\ndescribe : "); sb.append("gps定位成功"); } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {// 网络定位结果 sb.append("\naddr : "); sb.append(location.getAddrStr()); //运营商信息 sb.append("\noperationers : "); sb.append(location.getOperators()); sb.append("\ndescribe : "); sb.append("网络定位成功"); } else if (location.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果 sb.append("\ndescribe : "); sb.append("离线定位成功,离线定位结果也是有效的"); } else if (location.getLocType() == BDLocation.TypeServerError) { sb.append("\ndescribe : "); sb.append("服务端网络定位失败,可以反馈IMEI号和大体定位时间到[email protected],会有人追查原因"); } else if (location.getLocType() == BDLocation.TypeNetWorkException) { sb.append("\ndescribe : "); sb.append("网络不同导致定位失败,请检查网络是否通畅"); } else if (location.getLocType() == BDLocation.TypeCriteriaException) { sb.append("\ndescribe : "); sb.append("无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机"); } sb.append("\nlocationdescribe : "); sb.append(location.getLocationDescribe());// 位置语义化信息 List<Poi> list = location.getPoiList();// POI数据 if (list != null) { sb.append("\npoilist size = : "); sb.append(list.size()); for (Poi p : list) { sb.append("\npoi= : "); sb.append(p.getId() + " " + p.getName() + " " + p.getRank()); } } Log.i("BaiduLocationApiDem", sb.toString()); }
Example 12
Source File: MapActivity.java From foodie-app with Apache License 2.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { mLocation = location; PrefUtils.set("user", "location", mLocation.getAddrStr(), MapActivity.this.getBaseContext()); //Receive Location StringBuffer sb = new StringBuffer(256); sb.append("time : "); sb.append(location.getTime()); sb.append("\nerror code : "); sb.append(location.getLocType()); sb.append("\nlatitude : "); sb.append(location.getLatitude()); sb.append("\nlontitude : "); sb.append(location.getLongitude()); sb.append("\nradius : "); sb.append(location.getRadius()); if (location.getLocType() == BDLocation.TypeGpsLocation) {// GPS定位结果 sb.append("\nspeed : "); sb.append(location.getSpeed());// 单位:公里每小时 sb.append("\nsatellite : "); sb.append(location.getSatelliteNumber()); sb.append("\nheight : "); sb.append(location.getAltitude());// 单位:米 sb.append("\ndirection : "); sb.append(location.getDirection());// 单位度 sb.append("\naddr : "); sb.append(location.getAddrStr()); sb.append("\ndescribe : "); sb.append("gps定位成功"); mLocationView.setText(location.getAddrStr()); startLocationOverlap();//开启我的位置图层 } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {// 网络定位结果 sb.append("\naddr : "); sb.append(location.getAddrStr()); //运营商信息 sb.append("\noperationers : "); sb.append(location.getOperators()); sb.append("\ndescribe : "); sb.append("网络定位成功"); mLocationView.setText(location.getAddrStr()); startLocationOverlap();//开启我的位置图层 } else if (location.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果 sb.append("\ndescribe : "); sb.append("离线定位成功,离线定位结果也是有效的"); } else if (location.getLocType() == BDLocation.TypeServerError) { sb.append("\ndescribe : "); sb.append("服务端网络定位失败,可以反馈IMEI号和大体定位时间到[email protected],会有人追查原因"); mLocationView.setText("网络定位失败"); } else if (location.getLocType() == BDLocation.TypeNetWorkException) { sb.append("\ndescribe : "); sb.append("网络不同导致定位失败,请检查网络是否通畅"); mLocationView.setText("检查网络是否畅通"); } else if (location.getLocType() == BDLocation.TypeCriteriaException) { sb.append("\ndescribe : "); sb.append("无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机"); mLocationView.setText("您的手机无法定位"); } sb.append("\nlocationdescribe : "); sb.append(location.getLocationDescribe());// 位置语义化信息 List<Poi> list = location.getPoiList();// POI数据 if (list != null) { sb.append("\npoilist size = : "); sb.append(list.size()); for (Poi p : list) { sb.append("\npoi= : "); sb.append(p.getId() + " " + p.getName() + " " + p.getRank()); } } Log.i("BaiduLocationApiDem", sb.toString()); if (restaurantInfo != null) { search(restaurantInfo.getRestaurantName(), 1); mLocationView.setText("商家位置:" + restaurantInfo.getAddress()); } }
Example 13
Source File: NfcDeviceFragment.java From ESeal with Apache License 2.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { // TODO Auto-generated method stub if (null != location && location.getLocType() != BDLocation.TypeServerError) { String time = location.getTime(); double lat = location.getLatitude(); double lng = location.getLongitude(); String address = location.getAddrStr() + ", " + lat + "," + lng; // String address = lat + "," + lng; switch (operationSealSwitch) { case STATE_OPERATION_LOCK: //上封 lockTime.setText(time); lockLocation.setText(address); break; case STATE_OPERATION_UNLOCK: //解封 unlockTime.setText(time); unlockLocation.setText(address); break; case STATE_OPERATION_SETTING: //配置 coordinateSetting = lat + "," + lng; break; } } else if (null != location && location.getLocType() == BDLocation.TypeServerError) { switch (operationSealSwitch) { case STATE_OPERATION_LOCK: //上封 lockLocation.setText(getString(R.string.fail_get_current_location)); break; case STATE_OPERATION_UNLOCK: //解封 unlockLocation.setText(getString(R.string.fail_get_current_location)); break; } } else if (null != location && location.getLocType() == BDLocation.TypeNetWorkException) { switch (operationSealSwitch) { case STATE_OPERATION_LOCK: //上封 lockLocation.setText(getString(R.string.fail_get_current_location)); break; case STATE_OPERATION_UNLOCK: //解封 unlockLocation.setText(getString(R.string.fail_get_current_location)); break; } } else if (null != location && location.getLocType() == BDLocation.TypeCriteriaException) { switch (operationSealSwitch) { case STATE_OPERATION_LOCK: //上封 lockLocation.setText(getString(R.string.fail_get_current_location)); break; case STATE_OPERATION_UNLOCK: //解封 unlockLocation.setText(getString(R.string.fail_get_current_location)); break; } } isLocationServiceStarting = false; }
Example 14
Source File: DeviceOperationActivity.java From ESeal with Apache License 2.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { // TODO Auto-generated method stub if (null != location && location.getLocType() != BDLocation.TypeServerError) { String time = location.getTime(); double lat = location.getLatitude(); double lng = location.getLongitude(); String address = location.getAddrStr() + ", " + lat + "," + lng; // String address = lat + "," + lng; switch (operationSealSwitch) { case STATE_OPERATION_LOCK: //上封 lockTime.setText(time); lockLocation.setText(address); break; case STATE_OPERATION_UNLOCK: //解封 unlockTime.setText(time); unlockLocation.setText(address); break; case STATE_OPERATION_SETTING: //配置 coordinateSetting = lat + "," + lng; break; } } else if (null != location && location.getLocType() == BDLocation.TypeServerError) { switch (operationSealSwitch) { case STATE_OPERATION_LOCK: //上封 lockLocation.setText(getString(R.string.fail_get_current_location)); break; case STATE_OPERATION_UNLOCK: //解封 unlockLocation.setText(getString(R.string.fail_get_current_location)); break; } } else if (null != location && location.getLocType() == BDLocation.TypeNetWorkException) { switch (operationSealSwitch) { case STATE_OPERATION_LOCK: //上封 lockLocation.setText(getString(R.string.fail_get_current_location)); break; case STATE_OPERATION_UNLOCK: //解封 unlockLocation.setText(getString(R.string.fail_get_current_location)); break; } } else if (null != location && location.getLocType() == BDLocation.TypeCriteriaException) { switch (operationSealSwitch) { case STATE_OPERATION_LOCK: //上封 lockLocation.setText(getString(R.string.fail_get_current_location)); break; case STATE_OPERATION_UNLOCK: //解封 unlockLocation.setText(getString(R.string.fail_get_current_location)); break; } } isLocationServiceStarting = false; }
Example 15
Source File: DeviceMessageApplication.java From MapForTour with MIT License | 4 votes |
/** * 参数:location * 输出:location中的详细的位置信息 */ public String receiveLocationShowMessage(BDLocation location) { setLocation(location); longitude = location.getLongitude(); //经度 latitude = location.getLatitude(); //纬度 radius = location.getRadius(); //精度 address = location.getAddrStr(); this.latLng = new LatLng(latitude, longitude); //StringBuilder sb = new StringBuilder(256); // sb.append("经度:"); // sb.append(longitude); // sb.append(";纬度:"); // sb.append(latitude); // sb.append(";精度:"); // sb.append(radius); // sb.append("米"); // sb.append("\n错误代码:"); // sb.append(location.getLocType()); if (location.getLocType() == BDLocation.TypeGpsLocation) {// GPS定位结果 isLocateSuccess = true; isGPSLocation = true; latLngList.add(latLng); locateMode = "GPS定位"; // sb.append(";GPS定位成功"); // sb.append("\n速度:"); // sb.append(location.getSpeed());// 单位:公里每小时 // sb.append("km/s"); // sb.append(";星数:"); // sb.append(location.getSatelliteNumber()); // sb.append("颗;海拔:"); // sb.append(location.getAltitude());// 单位:米 // sb.append(";角度:"); // sb.append(location.getDirection());// 单位度 // sb.append("\n地址:"); // sb.append(location.getAddrStr()); } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {// 网络定位结果 isLocateSuccess = true; isGPSLocation = false; locateMode = "网络定位"; // sb.append(";网络定位成功"); // sb.append("\n运营商:"); // sb.append(location.getOperators()); // sb.append("\n地址:"); // sb.append(location.getAddrStr()); } else if (location.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果 isLocateSuccess = true; isGPSLocation = false; // sb.append("\n离线定位成功,离线定位结果也是有效的"); } else if (location.getLocType() == BDLocation.TypeServerError) { isLocateSuccess = false; isGPSLocation = false; // sb.append("\n服务端网络定位失败,可以反馈IMEI号和大体定位时间到[email protected],会有人追查原因"); } else if (location.getLocType() == BDLocation.TypeNetWorkException) { isLocateSuccess = false; isGPSLocation = false; // sb.append("\n网络不同导致定位失败,请检查网络是否通畅"); } else if (location.getLocType() == BDLocation.TypeCriteriaException) { isLocateSuccess = false; isGPSLocation = false; // sb.append("\n无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机"); } // sb.toString(); return "success"; }