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


Java BDLocation.getCity方法代碼示例

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


在下文中一共展示了BDLocation.getCity方法的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();
    }
}
 
開發者ID:gaolhjy,項目名稱:cniao5,代碼行數:18,代碼來源:CategoryFragment.java

示例2: onReceiveLocation

import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation arg0) {

	isNeedRefresh=false;
	if(arg0.getCity()==null){
		//定位失敗
		tvLocate.setText("未定位到城市,請選擇");
		tvCurrentLocateCity.setVisibility(View.VISIBLE);
		tvCurrentLocateCity.setText("重新選擇");
		pbLocate.setVisibility(View.GONE);
		return;
	}else{
		//定位成功
		currentCity=arg0.getCity().substring(0,arg0.getCity().length()-1);
		tvLocate.setText("當前定位城市");
		tvCurrentLocateCity.setVisibility(View.VISIBLE);
		tvCurrentLocateCity.setText(currentCity);
		myLocationClient.stop();
		pbLocate.setVisibility(View.GONE);
	}
}
 
開發者ID:jacksenh,項目名稱:CitySelct,代碼行數:22,代碼來源:CityListAdapter.java

示例3: onReceiveLocation

import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location){
    latitude = location.getLatitude();
    longitude = location.getLongitude();
    Log.d(TAG, "onReceiveLocation: "+latitude+" "+longitude);
    city = location.getCity();
    if(city != null){
        Log.d(TAG, city);
        //更新定位狀態
        mCityAdapter.updateLocateState(LocateState.SUCCESS,city.substring(0,city.length()-1));
        locateSuccess = true;
    }else {
        mCityAdapter.updateLocateState(LocateState.FAILED,null);
        locateSuccess = false;
    }

}
 
開發者ID:organizationAllink,項目名稱:wzyx-android-user,代碼行數:18,代碼來源:CityPickerActivity.java

示例4: onReceiveLocation

import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location){
    lat = location.getLatitude();
    lng = location.getLongitude();
    city = location.getCity();
    if(city != null){
        Log.d(TAG, city);
        if(!city.isEmpty()){
            //定位成功,更新定位狀態
            tvPosition.setText(city.substring(0,city.length()-1));
            showAndHideActivityList(SHOW);
            if(isFirstLoading){
                getActivityList(lat,lng);
                isFirstLoading = false;
            }else {
                getActivityListByType(mSelectedActivityType,mSelectedRankingType,lat,lng);
            }
        }else {
            tvPosition.setText(getResources().getString(R.string.locate));
            //定位失敗
            showAndHideActivityList(HIDE);
        }
    }


}
 
開發者ID:organizationAllink,項目名稱:wzyx-android-user,代碼行數:27,代碼來源:NearFragment.java

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

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

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

示例8: onReceiveLocation

import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
    MyLocationData data = new MyLocationData.Builder()
            .direction(mCurrentX)//更新當前方向
            .accuracy(400.0f)//精度
            .latitude(location.getLatitude())//緯度
            .longitude(location.getLongitude()).build();//經度
    mBaiduMap.setMyLocationData(data);
    //可在第三個參數設置自定義圖標
    MyLocationConfiguration config =
            new MyLocationConfiguration(mLocationMode, true, null);
    mBaiduMap.setMyLocationConfigeration(config);
    //更新經緯度
    mLatitude = location.getLatitude();
    mLongtitude = location.getLongitude();
    mCity = location.getCity();
    if (isFirstIn) {
        LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
        MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latLng);
        mBaiduMap.animateMapStatus(msu);
        isFirstIn = false;
        Toast.makeText(context, location.getAddrStr(), Toast.LENGTH_SHORT).show();
    }
}
 
開發者ID:PengZhiPeng,項目名稱:Mooc-map,代碼行數:25,代碼來源:MainActivity.java

示例9: onReceiveLocation

import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
	// map view 銷毀後不在處理新接收的位置
	if (location == null || mMapView == null)
		return;
	curMapCenterLatLng = mBaiduMap.getMapStatus().target;
	mCurrentLantitude = location.getLatitude();
	mCurrentLongitude = location.getLongitude();
	curCity = location.getCity();
	textView_curCity.setText(curCity);
	MyLocationData locData = new MyLocationData.Builder().accuracy(location.getRadius())
			// 此處設置開發者獲取到的方向信息,順時針0-360
			.direction(100).latitude(mCurrentLantitude).longitude(mCurrentLongitude).build();
	// 設置定位數據
	mBaiduMap.setMyLocationData(locData);
	if (isFirstLoc) {
		isFirstLoc = false;
		LatLng ll = new LatLng(mCurrentLantitude, mCurrentLongitude);
		MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
		mBaiduMap.animateMapStatus(u);
		getData();
	}

}
 
開發者ID:poomoo,項目名稱:eDao,代碼行數:25,代碼來源:MapActivity.java

示例10: onReceiveLocation

import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation bdLocation) {
    currentPosition = bdLocation.getCity();
    if (currentPosition != null){
        requestWeather(currentPosition);
        showShort(currentPosition + " 定位成功");
    }else{
        showShort("沒有獲取到定位權限,請打開定位權限後再打開此應用");
}
}
 
開發者ID:lentitude,項目名稱:BS-Weather,代碼行數:11,代碼來源:MainActivity.java

示例11: onReceiveLocation

import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
    if (isFirstLoc) {
        isFirstLoc = false;
        mCity = location.getCity();
        mProvince = location.getProvince();
        F.e("定位信息--------------------" + mProvince + "  " + mCity);
    }
}
 
開發者ID:mangestudio,項目名稱:GCSApp,代碼行數:10,代碼來源:AddPhoneActivity.java

示例12: onReceiveLocation

import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation bdLocation) {
    currentPosition = bdLocation.getCity();
    if (currentPosition != null){
        requestWeather(currentPosition);//傳入獲得的城市名稱
        showShort(currentPosition + " 定位成功");
    }else{
        showShort("定位錯誤,可能沒有獲取到定位權限,請打開定位權限後重新下打開此應用");
}
}
 
開發者ID:LynnYuki,項目名稱:CoolCloud-Weather,代碼行數:11,代碼來源:MainActivity.java

示例13: onReceiveLocation

import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation bdLocation) {
    currentPosition = bdLocation.getCity();
    if (currentPosition != null){
        MainActivity.actionStart(ChooseAreaActivity.this, currentPosition);//傳遞獲得的城市名稱給主活動
        showShort(currentPosition + " 定位成功");
        finish();
    }else{
        showShort("定位錯誤,可能沒有獲取到定位權限,請打開定位權限後重新下打開此應用");
    }
}
 
開發者ID:LynnYuki,項目名稱:CoolCloud-Weather,代碼行數:12,代碼來源:ChooseAreaActivity.java

示例14: prinftBDLocation

import com.baidu.location.BDLocation; //導入方法依賴的package包/類
public static void prinftBDLocation(BDLocation bdLocation) {
    Log.d("@@@", "====================BDLocation Strat====================");
    String str = "BDLocation{" + "locationID='" + bdLocation.getLocationID() + '\'' +
            ", locType=" + bdLocation.getLocType() +
            ", locTime='" + bdLocation.getTime() + '\'' +
            ", latitude=" + bdLocation.getLatitude() +
            ", longitude=" + bdLocation.getLongitude() +
            ", radius=" + bdLocation.getRadius() +
            ", addrStr=" + bdLocation.getAddrStr() +
            ", country='" + bdLocation.getCountry() + '\'' +
            ", countryCode='" + bdLocation.getCountryCode() + '\'' +
            ", city='" + bdLocation.getCity() + '\'' +
            ", cityCode='" + bdLocation.getCityCode() + '\'' +
            ", district='" + bdLocation.getDistrict() + '\'' +
            ", street='" + bdLocation.getStreet() + '\'' +
            ", streetNumber='" + bdLocation.getStreetNumber() + '\'' +
            ", locationDescribe='" + bdLocation.getLocationDescribe() + '\'' +
            ", buildingID='" + bdLocation.getBuildingID() + '\'' +
            ", buildingName='" + bdLocation.getBuildingName() + '\'' +
            ", floor='" + bdLocation.getFloor() + '\'' +
            ", speed=" + bdLocation.getSpeed() + '\'' +
            ", satelliteNumber=" + bdLocation.getSatelliteNumber() + '\'' +
            ", altitude=" + bdLocation.getAltitude() + '\'' +
            ", direction=" + bdLocation.getDirection() + '\'' +
            ", operators=" + bdLocation.getOperators() + '\'' +
            "}";
    Log.d("@@@", str);
    Log.d("@@@", "====================BDLocation End====================");
}
 
開發者ID:dreamfish797,項目名稱:LocationProvider,代碼行數:30,代碼來源:BaiduUtils.java

示例15: onReceiveLocation

import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation bdLocation) {
    if (bdLocation != null && !TextUtils.isEmpty(bdLocation.getCity())) {
        mCurrCity = bdLocation.getCity();
        sendParseDataMessage(LOAD_DATA_FINISH);
    } else {
        sendParseDataMessage(LOAD_DATA_ERROR);
    }

}
 
開發者ID:henryblue,項目名稱:TeaCup,代碼行數:11,代碼來源:WeatherActivity.java


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