当前位置: 首页>>代码示例>>Java>>正文


Java AMapLocation.getErrorCode方法代码示例

本文整理汇总了Java中com.amap.api.location.AMapLocation.getErrorCode方法的典型用法代码示例。如果您正苦于以下问题:Java AMapLocation.getErrorCode方法的具体用法?Java AMapLocation.getErrorCode怎么用?Java AMapLocation.getErrorCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amap.api.location.AMapLocation的用法示例。


在下文中一共展示了AMapLocation.getErrorCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
    if (mListener != null && aMapLocation != null) {
        if (aMapLocation != null && aMapLocation.getErrorCode() == 0) {
            mAMapLocation = aMapLocation;
            mlocationClient.stopLocation();
            mListener.onLocationChanged(aMapLocation);// 显示系统小蓝点
            lp = new LatLonPoint(aMapLocation.getLatitude(), aMapLocation.getLongitude());
            mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lp.getLatitude(), lp.getLongitude()), 17));
            doSearchQuery(aMapLocation.getPoiName().trim(), aMapLocation.getCityCode(), false);
        } else {
            String errText = "定位失败," + aMapLocation.getErrorCode() + ": " + aMapLocation.getErrorInfo();
            ToastUtils.showToast(this, errText);
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:PoiAroundSearchActivity.java

示例2: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
    if (aMapLocation != null) {
        if (aMapLocation.getErrorCode() == 0) {
            String lat = aMapLocation.getLatitude() + "";
            String lng = aMapLocation.getLongitude() + "";

            sharedPref.edit().putString("Latitude", lat).apply();
            sharedPref.edit().putString("Longitude", lng).apply();

        } else {
            Toast.makeText(
                    MainActivity.this,
                    aMapLocation.getErrorInfo(),
                    Toast.LENGTH_LONG
            ).show();
        }
    }
}
 
开发者ID:SEALiu,项目名称:Calendouer,代码行数:20,代码来源:MainActivity.java

示例3: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
     * 实现定位
     * @param amapLocation
     */
    @Override
    public void onLocationChanged(AMapLocation amapLocation) {
        if (mListener != null && amapLocation != null) {
            if (amapLocation != null
                    &&amapLocation.getErrorCode() == 0) {

                if(isFirstTime){//只要第一次的数据,当然,也可以在这里关闭定位
//                    mlocationClient.stopLocation();//停止定位
                    mListener.onLocationChanged(amapLocation);// 显示系统小蓝点
                    lvHolder.title = "[位置]";
                    lvHolder.address = amapLocation.getProvider()+amapLocation.getCity()+amapLocation.getStreet()+amapLocation.getStreetNum();
                    lvHolder.lp = new LatLonPoint(amapLocation.getLatitude(),amapLocation.getLongitude());
                    mEndMarker.setPosition(new LatLng(amapLocation.getLatitude(),amapLocation.getLongitude()));
                    data.add(0,lvHolder);
                    doSearchQuery();

                }

            } else {
                String errText = "定位失败," + amapLocation.getErrorCode()+ ": " + amapLocation.getErrorInfo();
                Log.e("AmapErr",errText);
            }
        }
    }
 
开发者ID:Vicent9920,项目名称:MyMap,代码行数:29,代码来源:PiclocationActivity.java

示例4: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
 * 定位地点
 * @param amapLocation
 */
@Override
public void onLocationChanged(AMapLocation amapLocation) {
    if (mListener != null&&amapLocation != null) {
        EventBus.getDefault().post(amapLocation);
        if (amapLocation != null
                &&amapLocation.getErrorCode() == 0) {
            if(startList.size()==0)
                startList.add(new NaviLatLng(amapLocation.getLatitude(),amapLocation.getLongitude()));
            if(!calculateSuccess){
                mListener.onLocationChanged(amapLocation);// 显示系统小蓝点
            }

        } else {
            String errText = "定位失败," + amapLocation.getErrorCode()+ ": " + amapLocation.getErrorInfo();
            Log.e("AmapErr",errText);
        }
    }
}
 
开发者ID:Vicent9920,项目名称:MyMap,代码行数:23,代码来源:NavigationActivity.java

示例5: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation loc) {
    if (null != loc && loc.getErrorCode() == 0) {
        //解析定位结果
        mLongitude = loc.getLongitude();
        mLatitude = loc.getLatitude();
        city = loc.getCity();
        country = loc.getCountry();
        Log.i("XLight", String.format("long:%s,latitude:%s,city:%s,country:%s", mLongitude, mLatitude, city, country));
        //请求天气信息
        updateLocationInfo();
        locationClient.stopLocation();
    } else {
        // 定位失败,显示提示
        Log.e("XLight", "location Error, ErrCode:"
                + loc.getErrorCode() + ", errInfo:"
                + loc.getErrorInfo());
        getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                ToastUtil.showToast(getActivity(), R.string.open_gps);
            }
        });
    }
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:26,代码来源:GlanceMainFragment.java

示例6: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
    if (aMapLocation != null) {
        if (aMapLocation.getErrorCode() == 0) {
            mCity = aMapLocation.getCity();
            mSwipeRefreshLayout.setEnabled(true);
            mSwipeRefreshLayout.post(new Runnable() {
                @Override
                public void run() {
                    mSwipeRefreshLayout.setRefreshing(true);
                }
            });
            getWeatherData(mCity);
        }
        //定位失败,通过ErrCode(错误码)信息来确定失败的原因,errInfo是错误信息
        else {
            SnackBarUtil.showSnackBar(aMapLocation.getErrorInfo(), mSwipeRefreshLayout, getActivity());
        }
    }
}
 
开发者ID:xiarunhao123,项目名称:PureNews,代码行数:21,代码来源:WeatherFragment.java

示例7: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation amapLocation) {
    if (amapLocation != null) {
        if (amapLocation.getErrorCode() == 0) {
            //可在其中解析amapLocation获取相应内容
            updateUserLocation(amapLocation.getCity());
            initCardWeather(amapLocation.getCity());
            mLocationClient.stopLocation();//停止定位后,本地定位服务并不会被销毁
        } else {
            //定位失败时,可通过ErrCode(错误码)信息来确定失败的原因,errInfo是错误信息,详见错误码表。
            Log.e("AmapError", "location Error, ErrCode:"
                    + amapLocation.getErrorCode() + ", errInfo:"
                    + amapLocation.getErrorInfo());
        }
    } else {

    }
}
 
开发者ID:monsterLin,项目名称:Pigeon,代码行数:19,代码来源:WeatherActivity.java

示例8: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
    if (mListener != null && aMapLocation != null) {
        if (aMapLocation != null
                && aMapLocation.getErrorCode() == 0) {

            LatLng location = new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude());
            if (!mFirstFix) {
                mFirstFix = true;
                addCircle(location, aMapLocation.getAccuracy());//添加定位精度圆
                addMarker(location);//添加定位图标
                mSensorHelper.setCurrentMarker(mLocMarker);//定位图标旋转
                mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, 18));
            } else {
                mCircle.setCenter(location);
                mCircle.setRadius(aMapLocation.getAccuracy());
                mLocMarker.setPosition(location);
                mAMap.moveCamera(CameraUpdateFactory.changeLatLng(location));
            }
        } else {
            String errText = "定位失败," + aMapLocation.getErrorCode() + ": " + aMapLocation.getErrorInfo();
            Log.e("AmapErr", errText);
        }
    }
}
 
开发者ID:InnoFang,项目名称:FamilyBond,代码行数:26,代码来源:MapActivity.java

示例9: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation amapLocation) {
    if (amapLocation != null) {
        if (amapLocation.getErrorCode() == 0) {
            //可在其中解析amapLocation获取相应内容。
            double locationType = amapLocation.getLocationType();//获取当前定位结果来源,如网络定位结果,详见定位类型表
            double latitude = amapLocation.getLatitude();//获取纬度
            double longitude = amapLocation.getLongitude();//获取纬度
            L.i("location", "locationType:" + locationType + ",latitude:" + latitude + ",longitude:" + longitude);
            LatLng latLng = new LatLng(latitude, longitude);
            getAddressByLatlng(latLng);
        } else {
            //定位失败时,可通过ErrCode(错误码)信息来确定失败的原因,errInfo是错误信息,详见错误码表。
            L.i("location", "location Error, ErrCode:"
                    + amapLocation.getErrorCode() + ", errInfo:"
                    + amapLocation.getErrorInfo());
        }
    }
}
 
开发者ID:InnoFang,项目名称:FamilyBond,代码行数:20,代码来源:HandleMessageService.java

示例10: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
 * 定位成功后回调函数
 */
@Override
public void onLocationChanged(AMapLocation amapLocation) {
	if (mListener != null && amapLocation != null) {
		if (amapLocation != null && amapLocation.getErrorCode() == 0) {
			tvResult.setVisibility(View.GONE);
			mListener.onLocationChanged(amapLocation);// 显示系统小蓝点
		} else {
			String errText = "定位失败," + amapLocation.getErrorCode() + ": "
					+ amapLocation.getErrorInfo();
			Log.e("AmapErr", errText);
			tvResult.setVisibility(View.VISIBLE);
			tvResult.setText(errText);
		}
	}
}
 
开发者ID:amapapi,项目名称:Android_Location_Demo,代码行数:19,代码来源:GeoFence_District_Activity.java

示例11: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation amapLocation) {
    if (amapLocation != null) {
        if (amapLocation.getErrorCode() == AMapLocation.LOCATION_SUCCESS) {
            Logger.e("经度 = " + amapLocation.getLongitude() + "\n" + "纬度 = " + amapLocation.getLatitude());
            if (!isWriteData) {
                writeData(amapLocation);
            }
        } else {
            //显示错误信息ErrCode是错误码,errInfo是错误信息,详见错误码表。
            Logger.e("AmapError", "location Error, ErrCode:"
                    + amapLocation.getErrorCode() + ", errInfo:"
                    + amapLocation.getErrorInfo());
        }
        RxBusManager.post(EventConstant.KEY_LOCATION, getLocationBean(amapLocation));
    }
}
 
开发者ID:pinguo-sunjianfei,项目名称:Android-Application-ZJB,代码行数:18,代码来源:LocationManager.java

示例12: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation amapLocation) {
	if (mListener != null && amapLocation != null) {
		if (amapLocation != null && amapLocation.getErrorCode() == 0) {
			mListener.onLocationChanged(amapLocation);// 显示系统小蓝点
			LatLng mylocation = new LatLng(amapLocation.getLatitude(),
					amapLocation.getLongitude());
			mAMap.moveCamera(CameraUpdateFactory.changeLatLng(mylocation));
			if (btn.isChecked()) {
				record.addpoint(amapLocation);
				mPolyoptions.add(mylocation);
				redrawline();
			}
		} else {
			String errText = "定位失败," + amapLocation.getErrorCode() + ": "
					+ amapLocation.getErrorInfo();
			Log.e("AmapErr", errText);
		}
	}
}
 
开发者ID:amapapi,项目名称:RecordPath3D,代码行数:21,代码来源:MainActivity.java

示例13: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
    //高德定位回调
    if (aMapLocation != null) {
        if (aMapLocation.getErrorCode() == 0) {
            updateLocation(aMapLocation);
            if (BuildConfig.DEBUG)
                MapUtil.showLocationInfor(aMapLocation);

        } else {
            //显示错误信息ErrCode是错误码,errInfo是错误信息,详见错误码表。
            if (BuildConfig.DEBUG) {
                LogMgr.e("AmapError", "location Error, ErrCode:"
                        + aMapLocation.getErrorCode() + ", errInfo:"
                        + aMapLocation.getErrorInfo());
            }
        }
    }
}
 
开发者ID:joy-inc,项目名称:joy-app,代码行数:20,代码来源:MapActivity.java

示例14: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
 * 定位监听回掉
 */
@Override
public void onLocationChanged(AMapLocation amapLocation) {
    if (mListener != null && amapLocation != null) {
        if (amapLocation.getErrorCode() == 0) {
            mCity = amapLocation.getCity();
            mCityTextView.setText(mCity);

            mPresenter.searchWeatherRecord(getContext(), amapLocation.getCity());

            mListener.onLocationChanged(amapLocation);// 显示系统小蓝点
        } else {
            String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo();
            Log.e("AmapErr", errText);
            //mLocationErrText.setVisibility(View.VISIBLE);
            //mLocationErrText.setText(errText);
        }
    }
}
 
开发者ID:Alex-ZHOU,项目名称:VMAndroid,代码行数:22,代码来源:RecordFragment.java

示例15: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
    public void onLocationChanged(AMapLocation amapLocation) {
        if (mListener != null && amapLocation != null) {
            if (amapLocation.getErrorCode() == 0) {
//                mCity = amapLocation.getCity();
//                mCityTextView.setText(mCity);
//
//                mPresenter.searchWeatherRecord(getContext(), amapLocation.getCity());

                mListener.onLocationChanged(amapLocation);// 显示系统小蓝点
            } else {
                String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo();
                Log.e("AmapErr", errText);
                //mLocationErrText.setVisibility(View.VISIBLE);
                //mLocationErrText.setText(errText);
            }
        }
    }
 
开发者ID:Alex-ZHOU,项目名称:VMAndroid,代码行数:19,代码来源:RecordDBActivity.java


注:本文中的com.amap.api.location.AMapLocation.getErrorCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。