本文整理汇总了Java中com.baidu.location.LocationClient.setAK方法的典型用法代码示例。如果您正苦于以下问题:Java LocationClient.setAK方法的具体用法?Java LocationClient.setAK怎么用?Java LocationClient.setAK使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.baidu.location.LocationClient
的用法示例。
在下文中一共展示了LocationClient.setAK方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
@Override
public void onCreate() {
Log.d("jabe", "location service onCreate.");
super.onCreate();
mHandler = new Handler();
locationClient = new LocationClient(this);
locationClient.setAK("BfkPvjDGHC0ATZhIr6wxnHh9");//设置百度的ak
LocationClientOption option = new LocationClientOption();
option.setOpenGps(true);
option.setScanSpan(3000);
option.setCoorType("bd09ll");// 返回的定位结果是百度经纬度,默认值gcj02
option.setProdName("BaiduLoc");
option.disableCache(true);// 禁止启用缓存定位
locationClient.setLocOption(option);
locationClient.registerLocationListener(myLocationListener);
}
示例2: initLocationClient
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
private void initLocationClient() {
client = new LocationClient(getApplicationContext());
CloudManager.getInstance().init(new MyCloudSearchListener());
client.setAK(myapp.getKEK());// ���ö�λ�����KEY
client.registerLocationListener(new MyLocationListener());// ע�����
LocationClientOption option = new LocationClientOption();// ���ö�λ����
option.setAddrType("all");// ����������Ϣ
option.disableCache(true);// �����涨λ��Ϣ
option.setCoorType("bd09ll");// ���ص���������
// option.setTimeOut(8000);���ö�λ��ʱ
client.setLocOption(option);// �������
}
示例3: initLocationClient
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
private void initLocationClient() {
client = new LocationClient(getApplicationContext());
MyApplication myapp = (MyApplication) this.getApplication();
client.setAK(myapp.getKEK());// ���ö�λ�����KEY
client.registerLocationListener(new BDLocationListener() {
public void onReceivePoi(BDLocation arg0) {
}
public void onReceiveLocation(BDLocation res) {
if (res != null) {
LocationData data = new LocationData();
data.latitude = res.getLatitude();
data.longitude = res.getLongitude();
data.accuracy = res.getRadius();
MyLocationOverlay locationOverlay = new MyLocationOverlay(
map);
GeoPoint poi = new GeoPoint(
(int) (res.getLatitude() * 1e6), (int) (res
.getLongitude() * 1e6));
locationOverlay.setData(data);
map.getOverlays().add(locationOverlay);
map.refresh();
map.getController().animateTo(poi);
probar.setVisibility(View.GONE);
flag.setVisibility(View.VISIBLE);
}
}
});// ע�����
LocationClientOption option = new LocationClientOption();// ���ö�λ����
option.setAddrType("all");// ����������Ϣ
option.disableCache(true);// �����涨λ��Ϣ
option.setCoorType("bd09ll");// ���ص���������
option.setTimeOut(8000);// ���ö�λ��ʱ
client.setLocOption(option);// �������
client.start();
}
示例4: initLocationClient
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
private void initLocationClient() {
client = new LocationClient(getApplicationContext());
client.setAK(myapp.getKEK());// ���ö�λ�����KEY
client.registerLocationListener(new BDLocationListener() {
public void onReceivePoi(BDLocation arg0) {
}
public void onReceiveLocation(BDLocation res) {
if (res.getAddrStr() == null) {
loctext.setText("��ȡλ��ʧ�ܣ�");
} else {
loctext.setText(res.getCity() + "," + res.getDistrict()
+ "," + res.getStreet() + ","
+ res.getStreetNumber());
// LocationData data=new LocationData();
// data.latitude=res.getLatitude();
// data.longitude=res.getLongitude();
// data.accuracy=res.getRadius();
// ((SchoolTripFragment)MainActivity.this.schooltrip).changeMyLocation(data);
}
}
});// ע�����
LocationClientOption option = new LocationClientOption();// ���ö�λ����
option.setAddrType("all");// ����������Ϣ
option.disableCache(true);// �����涨λ��Ϣ
option.setCoorType("bd09ll");// ���ص���������
option.setTimeOut(8000);// ���ö�λ��ʱ
client.setLocOption(option);// �������
client.start();
}
示例5: onCreate
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
userInfo = this.getSharedPreferences("setting", Context.MODE_PRIVATE);
global = Global.getInstance(userInfo.getString("dm_user", ""));
//����SharedPreferences
this.rwInfo=this.getSharedPreferences(this.getIntent().getIntExtra("rw_dm", 0)+"", Context.MODE_PRIVATE);
setContentView(R.layout.activity_get_lbs_tab);
// ��ͼ��ʼ��
mMapView = (MapView) findViewById(R.id.bmapsView);
mMapController = mMapView.getController();
mMapView.getController().setZoom(18);
mMapView.getController().enableClick(true);
mMapView.setBuiltInZoomControls(true);
// ���� ��������ͼ��
createPaopao();
// ��λ��ʼ��
mLocClient = new LocationClient(this);
locData = new LocationData();
mLocClient.registerLocationListener(myListener);
mLocClient.setAK(Utils.getMetaValue(getApplication(), "map_api_key"));
LocationClientOption option = new LocationClientOption();
option.setOpenGps(true);// ��gps
option.setCoorType("bd09ll"); // ������������
option.setScanSpan(1000);
option.setAddrType("all");
mLocClient.setLocOption(option);
mLocClient.start();
// ��λͼ���ʼ��
myLocationOverlay = new locationOverlay(mMapView);
// ���ö�λ����
myLocationOverlay.setData(locData);
// ��Ӷ�λͼ��
mMapView.getOverlays().add(myLocationOverlay);
myLocationOverlay.enableCompass();
// �Ķ�λ���ݺ�ˢ��ͼ����Ч
mMapView.refresh();
}
示例6: onCreate
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 初始化
initEngineManager(this);
// 布局获取ID
setContentView(R.layout.pyp_page_map);
mMapView = (MapView) findViewById(R.id.bmapView);
//实例化监听事件
mMapView.regMapViewListener(mBMapManager, mMapListener);
mMapView.regMapTouchListner(mapTouchListener);
//实例化工具
myLocationOverlay = new MyLocationOverlay(mMapView);
mLocClient = new LocationClient(this.getApplicationContext());
option = new LocationClientOption();
myListener = new MyLocationListenner();
locData = new LocationData();
mLocClient.setAK(APPCodeConst.ak);
mLocClient.registerLocationListener(myListener);
mLocClient.start();
mLocClient.requestLocation();
//对应方法
setOption();
}
示例7: onCreate
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tab_map);
mMapView = (MapView) findViewById(R.id.bmapsView);
mMapView.setBuiltInZoomControls(true);
// mMapView.setSatellite(true);
// �����������õ����ſؼ�
mMapController = mMapView.getController();
// �õ�mMapView�Ŀ���Ȩ,�����������ƺ�����ƽ�ƺ�����
locData = new LocationData();
locData.direction = 2.0f;
Intent intent = this.getIntent();
this.jd=intent.getDoubleExtra("jd", 0);
this.wd=intent.getDoubleExtra("wd", 0);
// ��ȡ���������
Log.d("wd", jd + "");
Log.d("jd", wd + "");
locData.latitude = wd;
locData.longitude = jd;
myLocationOverlay = new MyLocationOverlay(mMapView);
myLocationOverlay.setData(locData);
GeoPoint point = new GeoPoint((int) (locData.latitude * 1e6),
(int) (locData.longitude * 1e6));
// �ø����ľ�γ�ȹ���һ��GeoPoint����λ���� (�� * 1E6)
mMapController.setCenter(point);// ���õ�ͼ���ĵ�
mMapController.setZoom(18);// ���õ�ͼzoom����
mMapView.getOverlays().add(myLocationOverlay);
mMapView.refresh();
mMapView.getController().animateTo(point);
// ��ʼ��ȡ��ǰλ������
mLocClient = new LocationClient(this);
mLocClient.registerLocationListener(myListener);
mLocClient.setAK(Utils.getMetaValue(getApplication(), "map_api_key"));
LocationClientOption option = new LocationClientOption();
option.setOpenGps(true);// ��gps
option.setCoorType("bd09ll"); // ������������
option.setScanSpan(1000);
option.setAddrType("all");
mLocClient.setLocOption(option);
mLocClient.start();
}
示例8: onCreate
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
userInfo = this.getSharedPreferences("setting", Context.MODE_PRIVATE);
global = Global.getInstance(userInfo.getString("dm_user", ""));
// ����SharedPreferences
this.rwInfo = this.getSharedPreferences(
this.getIntent().getIntExtra("rw_dm", 0) + "",
Context.MODE_PRIVATE);
setContentView(R.layout.activity_get_lbs_tab);
// ��ͼ��ʼ��
mMapView = (MapView) findViewById(R.id.bmapsView);
mMapController = mMapView.getController();
mMapView.getController().setZoom(18);
mMapView.getController().enableClick(true);
mMapView.setBuiltInZoomControls(true);
// ���� ��������ͼ��
createPaopao();
// ��λ��ʼ��
mLocClient = new LocationClient(this);
locData = new LocationData();
mLocClient.registerLocationListener(myListener);
mLocClient.setAK(Utils.getMetaValue(getApplication(), "map_api_key"));
LocationClientOption option = new LocationClientOption();
option.setOpenGps(true);// ��gps
option.setCoorType("bd09ll"); // ������������
option.setScanSpan(1000);
option.setAddrType("all");
mLocClient.setLocOption(option);
mLocClient.start();
// ��λͼ���ʼ��
myLocationOverlay = new locationOverlay(mMapView);
// ���ö�λ����
myLocationOverlay.setData(locData);
// ��Ӷ�λͼ��
mMapView.getOverlays().add(myLocationOverlay);
myLocationOverlay.enableCompass();
// �Ķ�λ���ݺ�ˢ��ͼ����Ч
mMapView.refresh();
}
示例9: onCreate
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
KLog.d(TAG, "onCreate");
//加载保存信息
restoreAppInfo();
//设置定位相关参数
mLocationClient = new LocationClient(getApplicationContext());
mLocationClient.setAK(AppConfig.BAIDU_API_KEY); //设置Access Key
// 设置定位参数
mLocOpt.setOpenGps(true);
mLocOpt.setAddrType("all");//返回的定位结果包含地址信息
mLocOpt.setCoorType("gcj02");//返回的定位结果是gcj02,默认值gcj02
mLocOpt.setScanSpan(5000);//设置发起定位请求的间隔时间为5000ms
mLocOpt.disableCache(true);//禁止启用缓存定位
mLocOpt.setPoiNumber(5); //最多返回POI个数
mLocOpt.setPoiDistance(1000); //poi查询距离
mLocOpt.setPoiExtraInfo(true); //是否需要POI的电话和地址等详细信息
mLocationClient.setLocOption(mLocOpt);
mLocationClient.registerLocationListener(new BaseLocationListener());
//启动定位
mLocationClient.start();
//缓存设置
TACacheParams cacheParams = new TACacheParams(this, AppConfig.SYSTEMCACHE);
TAFileCache fileCache = new TAFileCache(cacheParams);
mFileCache = fileCache;
//图片缓存相关
TADownloadBitmapHandler f = new TADownloadBitmapHandler(this,
DensityUtils.dipTopx(this, 128),
DensityUtils.dipTopx(this, 128));
TABitmapCallBackHanlder taBitmapCallBackHanlder = new TABitmapCallBackHanlder();
taBitmapCallBackHanlder.setLoadingImage(this, R.drawable.empty_photo);
mImageFetcher = new TABitmapCacheWork(this);
mImageFetcher.setProcessDataHandler(f);
mImageFetcher.setCallBackHandler(taBitmapCallBackHanlder);
mImageFetcher.setFileCache(mFileCache);
//设置其他
SmartToast.initSingletonToast(getApplicationContext());
//读取当前登录的用户信息
getCurrentUserInfo();
//ImageLoader
DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
.cacheOnDisc(true)
.cacheInMemory(true)
.displayer(new FadeInBitmapDisplayer(50))
.bitmapConfig(Bitmap.Config.RGB_565)
.imageScaleType(ImageScaleType.EXACTLY)
.showImageOnLoading(R.drawable.empty_photo)
.showImageForEmptyUri(R.drawable.empty_photo)
.showImageOnFail(R.drawable.empty_photo)
.build();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.memoryCache(new UsingFreqLimitedMemoryCache(16 * 1024 * 1024))
.defaultDisplayImageOptions(defaultOptions).build();
ImageLoader.getInstance().init(config);
}