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


Java BDLocation.TypeOffLineLocation方法代碼示例

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


在下文中一共展示了BDLocation.TypeOffLineLocation方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例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 = 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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);
}
 
開發者ID:WindFromFarEast,項目名稱:SmartButler,代碼行數:79,代碼來源:LocationActivity.java

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

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

示例11: 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());
}
 
開發者ID:REBOOTERS,項目名稱:AndroidAnimationExercise,代碼行數:63,代碼來源:MyLocationListener.java

示例12: onReceiveLocation

import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation bdLocation) {
    if (finish) {
        return;
    }
    switch (bdLocation.getLocType()) {
        case BDLocation.TypeGpsLocation:
        case BDLocation.TypeNetWorkLocation:
        case BDLocation.TypeOffLineLocation:
            if (listener != null) {
                SharedPreferences sharedPreferences = c.getSharedPreferences(
                        PREFERENCE_LOCAL, Context.MODE_PRIVATE);
                String oldCity = sharedPreferences.getString(KEY_LAST_RESULT, ".");

                location.local = true;
                location.city = bdLocation.getDistrict();
                location.prov = bdLocation.getProvince();
                location.cnty = bdLocation.getCountry();
                location.lat = String.valueOf(bdLocation.getLatitude());
                location.lon = String.valueOf(bdLocation.getLongitude());

                sharedPreferences.edit()
                        .putString(KEY_LAST_RESULT, location.city)
                        .apply();

                if (!location.isUsable() || !location.city.equals(oldCity)) {
                    requestWeatherLocationByGeoPosition(
                            c,
                            location,
                            new SimpleWeatherLocationListener(location, listener));
                } else {
                    listener.requestLocationSuccess(location, false);
                }
                finish = true;
            }
            break;

        default:
            if (listener != null) {
                listener.requestLocationFailed(location);
            }
            break;
    }
}
 
開發者ID:WangDaYeeeeee,項目名稱:GeometricWeather,代碼行數:45,代碼來源:LocationHelper.java

示例13: 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.i("BaiduLocationApiDem", sb.toString());
	Log.d("loveMe", location.getCityCode());
	cityName = location.getCity().replace("市","");

}
 
開發者ID:k91191,項目名稱:bocaiWeather,代碼行數:75,代碼來源:BaiduLocate.java

示例14: receiveLocationShowMessage

import com.baidu.location.BDLocation; //導入方法依賴的package包/類
/**
     * 參數: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";
    }
 
開發者ID:bitkylin,項目名稱:MapForTour,代碼行數:68,代碼來源:DeviceMessageApplication.java

示例15: onReceiveLocation

import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
	// BDLocation類封裝了定位sdk的定位結果
    // 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());
        }
    }
    LogUtil.i(sb.toString());
    
    Location myLocation = new Location();
    myLocation.setLongitude(location.getLongitude());
    myLocation.setLatitude(location.getLatitude());
    myLocation.setAddress(location.getAddrStr());
    myLocation.setAddressDes(location.getLocationDescribe());
    mLocationListener.onReceiveLocation(myLocation);
}
 
開發者ID:weiwosuoai,項目名稱:sniff_wifi,代碼行數:71,代碼來源:LocationManager.java


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