當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。