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


Java BDLocation.getLocType方法代碼示例

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


在下文中一共展示了BDLocation.getLocType方法的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) {

    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();
    }
}
 
開發者ID:gaolhjy,項目名稱:cniao5,代碼行數:18,代碼來源:CategoryFragment.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 = 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

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

示例5: 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"));
    }

}
 
開發者ID:yangjiantao,項目名稱:AndroidLocationLib,代碼行數:22,代碼來源:LocationHelper.java

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

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

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

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

示例10: 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();
            }

        }
    };


}
 
開發者ID:BeckNiu,項目名稱:MyCar,代碼行數:22,代碼來源:RoadFragment.java

示例11: onMessageEvent

import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Subscribe
public void onMessageEvent(FirstEvent event) {
    BDLocation location = event.getLocation();
    switch (location.getLocType()) {
        case 161:
            //Toast.makeText(this, "定位失敗,請重新定位", Toast.LENGTH_SHORT).show();
            break;
        case 62:
            Toast.makeText(this, "無法獲取有效定位依據,定位失敗,請檢查運營商網絡或者wifi網絡是否正常開啟,嘗試重新請求定位", Toast.LENGTH_SHORT).show();
            break;
        default:

            break;
    }
    if (location.getLocType() != 161) {
        Toast.makeText(this, location.getLocationDescribe() + "", Toast.LENGTH_SHORT).show();
    } else {
        messages.setText(location.getLatitude() + "緯度" + location.getLongitude() + "緯度" + location.getCity() + "城市" + location.getLocType() + "errocode");
    }
    //Toast.makeText(this, event.getStringBuffer().toString(), Toast.LENGTH_SHORT).show();
}
 
開發者ID:Room3,項目名稱:Retrofitdemo,代碼行數:22,代碼來源:MainActivity.java

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

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

示例14: onReceiveLocation

import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@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));
        Logger.d("發送了");
    } 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();

}
 
開發者ID:byhieg,項目名稱:easyweather,代碼行數:19,代碼來源:MyLocationListener.java

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


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