本文整理匯總了Java中com.baidu.location.BDLocation.TypeGpsLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java BDLocation.TypeGpsLocation方法的具體用法?Java BDLocation.TypeGpsLocation怎麽用?Java BDLocation.TypeGpsLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.baidu.location.BDLocation
的用法示例。
在下文中一共展示了BDLocation.TypeGpsLocation方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
// StringBuilder currentPosition=new StringBuilder();
// currentPosition.append("緯度:").append(location.getLatitude()).append("\n");
// currentPosition.append("經線:").append(location.getLongitude()).append("\n");
// currentPosition.append("國家:").append(location.getCountry()).append("\n");
// currentPosition.append("省:").append(location.getProvince()).append("\n");
// currentPosition.append("市:").append(location.getCity()).append("\n");
// currentPosition.append("區:").append(location.getDistrict()).append("\n");
// currentPosition.append("街道:").append(location.getStreet()).append("\n");
// currentPosition.append("定位方式: ");
// if (location.getLocType()==BDLocation.TypeGpsLocation){
// currentPosition.append("GPS");
// }else if (location.getLocType()==BDLocation.TypeNetWorkLocation){
// currentPosition.append("網絡");
// }
// positionText.setText(currentPosition);
// }
// });
if (location.getLocType()==BDLocation.TypeGpsLocation||location.getLocType()==BDLocation.TypeNetWorkLocation){
navigateTo(location);
}
}
示例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: 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;
}
示例5: 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;
}
}
示例6: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location)
{
if (location.getLocType() == BDLocation.TypeGpsLocation || location
.getLocType() == BDLocation.TypeNetWorkLocation || location
.getLocType() == BDLocation.TypeOffLineLocation)
{
mTv.setText(location.getAddrStr());
//將經緯度保存到服務器
EventBus.getDefault().post(new EventLocate(location.getLatitude(),
location.getLongitude()));
} else
{
Toast.makeText(mContext, "定位失敗,檢查網絡是否通暢", Toast.LENGTH_SHORT).show();
}
LocationUtils.stopClient();
}
示例7: isLocationValid
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
public static boolean isLocationValid(BDLocation location) {
if (location == null)
return false;
if (location.getLongitude() <= 73)
return false;
if (location.getLongitude() >= 136)
return false;
if (location.getLatitude() <= 3)
return false;
if (location.getLatitude() >= 54)
return false;
if (location.getRadius() == 0)
return false;
if (location.getRadius() == 2000)
return false;
if (location.getLocType() == BDLocation.TypeCacheLocation)
return true;
if (location.getLocType() == BDLocation.TypeGpsLocation)
return true;
if (location.getLocType() == BDLocation.TypeNetWorkLocation)
return true;
if (location.getLocType() == BDLocation.TypeOffLineLocation)
return true;
return false;
}
示例8: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation bdLocation) {
if (bdLocation == null) {
Toast.makeText(AutoUpdateService.this, "網絡定位失敗", Toast.LENGTH_SHORT).show();
return;
}
if (bdLocation.getLocType() == BDLocation.TypeNetWorkLocation
|| bdLocation.getLocType() == BDLocation.TypeGpsLocation) {
//也可以使用 bdLocation.getWeatherIdAndCityName()
if (bdLocation.getDistrict() != null) {
Log.d(TAG, "onReceiveLocation: " + bdLocation.getDistrict());
if (handler != null) {
districtName = bdLocation.getDistrict();
latitude = bdLocation.getLatitude();
longitude = bdLocation.getLongitude();
//根據地址查詢該地區天氣 ID
queryCountryIdFromName(districtName);
//Toast.makeText(AutoUpdateService.this, "定位地址是:" + districtName, Toast.LENGTH_SHORT).show();
}
}
}
}
示例9: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(final BDLocation bdLocation) {
final StringBuilder currentPosition = new StringBuilder();
currentPosition.append("緯度:").append(bdLocation.getLatitude()).append("\n")
.append("經度:").append(bdLocation.getLongitude()).append("\n")
.append("國家:").append(bdLocation.getCountry()).append("\n")
.append("省:").append(bdLocation.getProvince()).append("\n")
.append("市:").append(bdLocation.getCity()).append("\n")
.append("區:").append(bdLocation.getDistrict()).append("\n")
.append("街道:").append(bdLocation.getStreet()).append("\n")
.append("定位方式:");
if (bdLocation.getLocType() == BDLocation.TypeGpsLocation) {
currentPosition.append("GPS");
} else if (bdLocation.getLocType() == BDLocation.TypeNetWorkLocation) {
currentPosition.append("網絡");
}
runOnUiThread(new Runnable() {
@Override
public void run() {
mTvBaiduMapPosition.setText(currentPosition.toString());
navigateTo(bdLocation);
}
});
}
示例10: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的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;
}
}
示例11: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation loc) {
if (locationClient.isStarted()) {
locationClient.stop();
}
JSONObject jo = new JSONObject();
try {
jo.put("longitude", loc.getLongitude());
jo.put("latitude", loc.getLatitude());
jo.put("address", loc.getAddrStr());
jo.put("hasRadius ", loc.hasRadius());
jo.put("radius", loc.getRadius());
int type = loc.getLocType();
String typeStr = (type == BDLocation.TypeGpsLocation?"gps":(type==BDLocation.TypeNetWorkLocation?"網絡":"其它"));
jo.put("type",typeStr);
} catch (JSONException e) {
jo = null;
e.printStackTrace();
}
if(jo!=null) {
Log.d("LocationPlugin", "location:"+jo.toString());
callbackContext.success(jo);
}
}
示例12: callBackGetPosOnce
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
private void callBackGetPosOnce(BDLocation location) {
if (callbackContext != null) {
if (location != null) {
try {
JSONObject jsonObj = new JSONObject();
JSONObject coords = new JSONObject();
coords.put("latitude", location.getLatitude());
coords.put("longitude", location.getLongitude());
coords.put("radius", location.getRadius());
jsonObj.put("coords", coords);
int locationType = location.getLocType();
jsonObj.put("locationType", locationType);
jsonObj.put("code", locationType);
switch (location.getLocType()) {
case BDLocation.TypeGpsLocation:
coords.put("speed", location.getSpeed());
coords.put("altitude", location.getAltitude());
jsonObj.put("SatelliteNumber",
location.getSatelliteNumber());
break;
case BDLocation.TypeNetWorkLocation:
jsonObj.put("addr", location.getAddrStr());
break;
}
Log.d("jabe", "call back once pos : " + jsonObj.toString());
callbackContext.success(jsonObj.toString());
} catch (Throwable e) {
e.printStackTrace();
callbackContext.error("remote service error.");
}
} else {
callbackContext.error(" service not connected error.");
}
}
}
示例13: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
public void onReceiveLocation(BDLocation location) {
if (location.getLocType() == BDLocation.TypeGpsLocation) {// 通過GPS定位
sb = location.getAddrStr();// 獲得當前地址
} else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {// 通過網絡連接定位
sb = location.getAddrStr();// 獲得當前地址
}
}
示例14: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
LocationIntentService.this.mCurLocation = location;
synchronized (LocationIntentService.this.mSyncObject) {
LocationIntentService.this.mSyncObject.notifyAll();
}
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());
sb.append("\ntype : ");
sb.append(location.getLocType());
if (location.getLocType() == BDLocation.TypeGpsLocation) {
sb.append("\nspeed : ");
sb.append(location.getSpeed());
sb.append("\nsatellite : ");
sb.append(location.getSatelliteNumber());
} else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {
sb.append("\naddr : ");
sb.append(location.getAddrStr());
}
Log.d(TAG, sb.toString());
}
示例15: 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){
sb.append("\nspeed : ");
sb.append(location.getSpeed());
sb.append("\nsatellite : ");
sb.append(location.getSatelliteNumber());
sb.append("\ndirection : ");
sb.append(location.getDirection());
} else if (location.getLocType() == BDLocation.TypeNetWorkLocation){
sb.append("\naddr : ");
sb.append(location.getAddrStr());
//��Ӫ����Ϣ
sb.append("\noperationers : ");
sb.append(location.getOperators());
}
logMsg(sb.toString());
Log.i(TAG, sb.toString());
}