當前位置: 首頁>>代碼示例>>Java>>正文


Java BDLocation.TypeNetWorkLocation方法代碼示例

本文整理匯總了Java中com.baidu.location.BDLocation.TypeNetWorkLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java BDLocation.TypeNetWorkLocation方法的具體用法?Java BDLocation.TypeNetWorkLocation怎麽用?Java BDLocation.TypeNetWorkLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.baidu.location.BDLocation的用法示例。


在下文中一共展示了BDLocation.TypeNetWorkLocation方法的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);
            }
        }
 
開發者ID:Qinlong275,項目名稱:AndroidBookTest,代碼行數:27,代碼來源:MainActivity.java

示例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);
    }
}
 
開發者ID:liying2008,項目名稱:Simpler,代碼行數:22,代碼來源:WBNearbyActivity.java

示例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);
    }
}
 
開發者ID:liying2008,項目名稱:Simpler,代碼行數:24,代碼來源:WBPostActivity.java

示例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;
}
 
開發者ID:dreamfish797,項目名稱:LocationProvider,代碼行數:30,代碼來源:BaiduUtils.java

示例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;
    }
}
 
開發者ID:aduroidpc,項目名稱:TaskNotepad,代碼行數:17,代碼來源:OneFragment.java

示例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();
}
 
開發者ID:ChenAt,項目名稱:PlayTogether,代碼行數:18,代碼來源:InvitationCategoryAdapter.java

示例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;
}
 
開發者ID:iWay7,項目名稱:BikeHelper,代碼行數:26,代碼來源:LocationUtils.java

示例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();
            }
        }
    }
}
 
開發者ID:AlphaGao1993,項目名稱:CoolerWeather,代碼行數:23,代碼來源:AutoUpdateService.java

示例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);
        }
    });
}
 
開發者ID:DysaniazzZ,項目名稱:HelloAndroid,代碼行數:25,代碼來源:BaiduMapUsageActivity.java

示例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;
    }
}
 
開發者ID:mylukin,項目名稱:geshui,代碼行數:21,代碼來源:MainActivity.java

示例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);
	}
}
 
開發者ID:kaixinhupo,項目名稱:cordova_location,代碼行數:25,代碼來源:LocationPlugin.java

示例12: onReceivePoi

import com.baidu.location.BDLocation; //導入方法依賴的package包/類
public void onReceivePoi(BDLocation poiLocation) {
    if (poiLocation == null) {
        Location.mLocationClient.requestPoi();
        return;
    }
    Location.locInfo.setLongitude(poiLocation.getLongitude());
    Location.locInfo.setLatitude(poiLocation.getLatitude());
    if (poiLocation.getLocType() == BDLocation.TypeNetWorkLocation) {
        Location.locInfo.setAddr(poiLocation.getAddrStr());
        Log.i(Location.TAG, "onaddr");
    }
    if (poiLocation.hasPoi()) {
        Location.locInfo.setPoiStr(poiLocation.getPoi());
    }
}
 
開發者ID:JamesLiAndroid,項目名稱:AndroidKillerService,代碼行數:16,代碼來源:Location.java

示例13: 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.");
        }
    }
}
 
開發者ID:jabelai,項目名稱:location-phonegap,代碼行數:36,代碼來源:BaiduLocation.java

示例14: 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();// 獲得當前地址
			}

		}
 
開發者ID:haiyangxue,項目名稱:EasyTracker,代碼行數:10,代碼來源:LocationApplication.java

示例15: 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());
}
 
開發者ID:legendmohe,項目名稱:LEHomeMobile_android,代碼行數:33,代碼來源:LocationIntentService.java


注:本文中的com.baidu.location.BDLocation.TypeNetWorkLocation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。