本文整理匯總了Java中com.baidu.location.BDLocation.TypeServerError方法的典型用法代碼示例。如果您正苦於以下問題:Java BDLocation.TypeServerError方法的具體用法?Java BDLocation.TypeServerError怎麽用?Java BDLocation.TypeServerError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.baidu.location.BDLocation
的用法示例。
在下文中一共展示了BDLocation.TypeServerError方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
if (null != location && location.getLocType() != BDLocation.TypeServerError) {
cityName = location.getCity();
provinceName = location.getProvince();
if (cityName != null) {
mCityName.setText(cityName.substring(0, cityName.length() - 1));
} else {
mCityName.setText("上海");
}
getCityWeather();
} else {
getCityWeather();
}
}
示例2: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@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);
}
}
示例3: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@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);
}
}
示例4: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public final void onReceiveLocation(BDLocation bdLocation) {
if (null != bdLocation && bdLocation.getLocType() != BDLocation.TypeServerError) {
LocationEntity location = new LocationEntity(bdLocation);
onReceiveLocation(location);
String errorMsg = null;
if (bdLocation.getLocType() == BDLocation.TypeServerError) {
errorMsg = "服務端網絡定位失敗,可以反饋IMEI號和大體定位時間到[email protected],會有人追查原因";
} else if (bdLocation.getLocType() == BDLocation.TypeNetWorkException) {
errorMsg = "網絡不同導致定位失敗,請檢查網絡是否通暢";
} else if (bdLocation.getLocType() == BDLocation.TypeCriteriaException) {
errorMsg = "無法獲取有效定位依據導致定位失敗,一般是由於手機的原因,處於飛行模式下一般會造成這種結果,可以試著重啟手機";
}
if (!TextUtils.isEmpty(errorMsg)) {
onError(new Throwable(errorMsg));
}
} else {
onError(new Throwable("uncaught exception"));
}
}
示例5: isValidLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
/**
* 判斷位置是否可用
*
* @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;
}
示例6: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
switch (location.getLocType()) {
case BDLocation.TypeGpsLocation:
case BDLocation.TypeNetWorkLocation:
case BDLocation.TypeOffLineLocation:
getWeather(location.getCity());
break;
case BDLocation.TypeServerError:
case BDLocation.TypeNetWorkException:
case BDLocation.TypeCriteriaException:
//如果定位失敗,默認失敗
getWeather("深圳");
break;
}
}
示例7: getCity
import com.baidu.location.BDLocation; //導入方法依賴的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();
}
}
};
}
示例8: Getctiy
import com.baidu.location.BDLocation; //導入方法依賴的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;
}
示例9: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
String hid = mSession.getHotelid()==0?"":(String.valueOf(mSession.getHotelid()));
if (null != location && location.getLocType() != BDLocation.TypeServerError) {
double latitude = location.getLatitude();
double longitude = location.getLongitude();
mSession.setLatestLat(latitude);
mSession.setLatestLng(longitude);
}
}
示例10: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
if (null != location && location.getLocType() != BDLocation.TypeServerError) {
mLatitude = location.getLatitude();
mLongitude = location.getLongitude();
mNearbyPersonPresenter.getNearbyPersons(mUserId,String.valueOf(mLongitude),String.valueOf(mLatitude),mSex);
mBaiduMap.clear();
mBaiduMap.setMyLocationEnabled(false);
//停止定位服務
mLocationService.stop();
//需要將mitems中的數據清空
if (mItems != null && mItems.size() > 0) {
mItems.clear();
}
//第一次定位到當前的位置
// 顯示到定位的地方
//為了取消定位藍點,設置了setMyLocationEnabled(false),所以下麵的代碼實際上不起作用
LatLng ll = new LatLng(location.getLatitude(),
location.getLongitude());
MapStatus.Builder builder = new MapStatus.Builder();
builder.target(ll).zoom(16.0f);
mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()), 300);
} else {
//定位失敗就不繼續定位了
// Toast.makeText(getActivity(), "定位失敗,失敗碼是:" + location.getLocType(), Toast.LENGTH_SHORT).show();
Log.d("----", "onReceiveLocation: 定位失敗,失敗碼是:"+location.getLocType());
}
}
示例11: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation 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());
}
}
//移動到用戶當前位置
moveToMe(location);
}
示例12: displayLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
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);
}
示例13: analysisLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
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;
}
示例14: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@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());
}
示例15: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@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;
}