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


Java LocationClient.setAK方法代码示例

本文整理汇总了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);
}
 
开发者ID:jabelai,项目名称:location-phonegap,代码行数:17,代码来源:LocationCacheService.java

示例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);// �������
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:13,代码来源:MapActivity.java

示例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();
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:38,代码来源:PoiSelectActivity.java

示例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();
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:31,代码来源:MainActivity.java

示例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();
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:41,代码来源:GetLbsTab.java

示例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();
       
}
 
开发者ID:steven2947,项目名称:NeXT_pyp,代码行数:32,代码来源:BMapLocActivity.java

示例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();
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:50,代码来源:LjghTab.java

示例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();
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:43,代码来源:DaoHangTab.java

示例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);
}
 
开发者ID:alexcaisenchuan,项目名称:FunWeibo,代码行数:64,代码来源:AppControl.java


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