com.baidu.mapapi.SDKInitializer Java Examples

The following examples show how to use com.baidu.mapapi.SDKInitializer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExampleApp.java    From FastWaiMai with MIT License 6 votes vote down vote up
/**
 * 访问本机地址须使用IP地址访问无法使用localhost形式
 */
@Override
public void onCreate() {
    super.onCreate();
    final ArrayList<Interceptor> interceptors = initInterceptors();

    Latte.init(this)
            .withApiHost("http://192.168.1.54:8082")
            .withInterceptors(interceptors)
            .withIcon(new FontAwesomeModule())
            .withJavascriptInterface("latte")
            .withWebEvent("test",new TestEvent())
            .configure();
    //在使用SDK各组件之前初始化context信息,传入ApplicationContext
    SDKInitializer.initialize(this);
    //自4.3.0起,百度地图SDK所有接口均支持百度坐标和国测局坐标,用此方法设置您使用的坐标类型.
    //包括BD09LL和GCJ02两种坐标,默认是BD09LL坐标。
    SDKInitializer.setCoordType(CoordType.BD09LL);
 Fragmentation.builder()
   // 显示悬浮球 ; 其他Mode:SHAKE: 摇一摇唤出   NONE:隐藏
   .stackViewMode(Fragmentation.SHAKE)
   .debug(BuildConfig.DEBUG)
            .install();

}
 
Example #2
Source File: BusActivity.java    From BaiduMap-TrafficAssistant with MIT License 6 votes vote down vote up
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	SDKInitializer.initialize(getApplicationContext());
	setContentView(R.layout.activity_bus);
	this.context = this;

	initView();// 省市联动;
	initAdapter();// 省市联动;
	province.setAdapter(arrayAdapterProvince);

	mBaiduMap = ((SupportMapFragment) getSupportFragmentManager()
			.findFragmentById(R.id.bmapView)).getBaiduMap();
	mSearch = PoiSearch.newInstance();
	mBusLineSearch = BusLineSearch.newInstance();
	initListener();
	busLineIDList = new ArrayList<String>();

}
 
Example #3
Source File: MapActivity.java    From BaiduMap-TrafficAssistant with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	// 以下这行代码作用:消除标题栏,但会出现bug。会隐藏掉menu菜单。不用该代码。
	// requestWindowFeature(Window.FEATURE_NO_TITLE);

	// 以下这行代码作用:使地图全屏显示,隐藏状态栏
	// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
	// WindowManager.LayoutParams.FLAG_FULLSCREEN);

	// 在使用SDK各组件之前初始化context信息,传入ApplicationContext
	// 注意该方法要再setContentView方法之前实现
	SDKInitializer.initialize(getApplicationContext());
	// 怎样快速导入导入包的快捷键
	// Ctrl+Shift+o

	setContentView(R.layout.activity_map);// 加载主界面,这个主界面就是地图界面

	this.context = this;

	initView();

	// 初始化定位
	initLocation();

}
 
Example #4
Source File: App.java    From ESeal with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    mApplicationContext = this;

    /***
     * 初始化版本升级模块
     */
    UpdateConfig.initGet(this);

    /***
     * 初始化定位sdk,建议在Application中创建
     */
    locationService = new LocationService(getApplicationContext());
    mVibrator = (Vibrator) getApplicationContext().getSystemService(VIBRATOR_SERVICE);
    SDKInitializer.initialize(getApplicationContext());
}
 
Example #5
Source File: MainActivity.java    From Mobike with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SDKInitializer.initialize(getApplicationContext());//必须放在这里
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    myUser = MyApplication.getInstance().getUser();
    if (myUser != null)
        isNeedLogin = false;
    else {
        isNeedLogin = true;
    }
    Log.d(TAG, "initData: " + isNeedLogin);

    initMap();
    requesPemission();
    initViews();
    isServiceLive = Utils.isServiceWork(this, "com.yiwen.mobike.service.RouteService");
    if (isServiceLive)
        beginService();

    initData();

    initEvent();

}
 
Example #6
Source File: MyApplication.java    From Mobike with Apache License 2.0 6 votes vote down vote up
private void initMyApplication() {
    //tencent bugly
    CrashReport.initCrashReport(getApplicationContext(), "e1a62089c6", false);
    //Fresco
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
            .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())
            .build();
    Fresco.initialize(this, config);
    //baidu map sdk
    SDKInitializer.initialize(this);
    //Bmob
    Bmob.initialize(this, "b0cb494256d9b86fc931ca930a055b75");
    //Logger
    Logger.addLogAdapter(new AndroidLogAdapter(){
        @Override
        public boolean isLoggable(int priority, String tag) {
            return true;// TODO: 2017/6/5
        }
    });
    //locail use data
    initUser();
}
 
Example #7
Source File: NearbyGroupWithRedPocketMapViewActivity.java    From Social with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.nearby_group_with_redpocket_mapview_activity_layout);

    is_first_page = getIntent().getIntExtra("is_first_page",0);

    handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what){
                case OkhttpUtil.MESSAGE_RED_POCKET_GROUP:
                    handleRedpocketGroupList(msg);
                    break;
            }
        }
    };

    initView();

    getRedPocketGroupList();

}
 
Example #8
Source File: ShareLocationActivity.java    From imsdk-android with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SDKInitializer.initialize(getApplicationContext());
    shareId = getIntent().getStringExtra(SHARE_ID);
    fromId = getIntent().getStringExtra(FROM_ID);
    myId = QtalkStringUtils.userId2Jid(CurrentPreference.getInstance().getUserid());
    presenter.setShareLocationView(this);
    setContentView(R.layout.atom_ui_activity_share_location);
    mapView = (MapView) findViewById(R.id.mapView);
    img_reset_location = (ImageView) findViewById(R.id.img_reset_location);
    hint = (TextView) findViewById(R.id.hint);
    topContainer = (LinearLayout) findViewById(R.id.location_top_container);
    actionBar = (QtNewActionBar) findViewById(R.id.my_action_bar);
    setNewActionBar(actionBar);
    initBaiduMap();
    img_reset_location.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            zoomMap();
        }
    });
    addMember(myId);
}
 
Example #9
Source File: JGApplication.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    context = getApplicationContext();
    StorageUtil.init(context, null);

    Fresco.initialize(getApplicationContext());
    SDKInitializer.initialize(getApplicationContext());
    locationService = new LocationService(getApplicationContext());

    JMessageClient.init(getApplicationContext(), true);
    JMessageClient.setDebugMode(true);
    SharePreferenceManager.init(getApplicationContext(), JCHAT_CONFIGS);
    //设置Notification的模式
    JMessageClient.setNotificationFlag(JMessageClient.FLAG_NOTIFY_WITH_SOUND | JMessageClient.FLAG_NOTIFY_WITH_LED | JMessageClient.FLAG_NOTIFY_WITH_VIBRATE);
    //注册Notification点击的接收器
    new NotificationClickEventReceiver(getApplicationContext());
    initImagePicker();

}
 
Example #10
Source File: FreightTrackMapActivity.java    From ESeal with Apache License 2.0 5 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //初始化百度地图API
        SDKInitializer.initialize(getApplicationContext());

        setContentView(R.layout.activity_toolbar_frame_fab);

        mFreight = getIntent().getParcelableExtra(EXTRA_FREIGHT);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitle(mFreight.getName());
        toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
        setSupportActionBar(toolbar);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });

//        attachDeviceFragment();
//        attachDeviceGoogleMapFragment(); //test GoogleMap
        attachDeviceWithWebViewFragment(); //using WebView & BaiduMap

        supportPostponeEnterTransition();
    }
 
Example #11
Source File: DownloadActivity.java    From BaiduMap-TrafficAssistant with MIT License 5 votes vote down vote up
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	this.context = this;
	SDKInitializer.initialize(getApplicationContext());
	setContentView(R.layout.activity_download);
	mOffline = new MKOfflineMap();
	mOffline.init(this);
	initView();
	initAdapter();
	province.setAdapter(arrayAdapterProvince);

}
 
Example #12
Source File: NavigationActivity.java    From BaiduMap-TrafficAssistant with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	SDKInitializer.initialize(getApplicationContext());
	this.context = this;
	setContentView(R.layout.activity_navigation);
	initView();

	// 初始化搜索模块,注册事件监听
	mSearch = GeoCoder.newInstance();
	mSearch.setOnGetGeoCodeResultListener(this);
}
 
Example #13
Source File: LocationActivity.java    From Conquer with Apache License 2.0 5 votes vote down vote up
private void initBaiduMap() {
	// 地图初始化
	mMapView = (MapView) findViewById(R.id.bmapView);
	mBaiduMap = mMapView.getMap();
	// 设置缩放级别
	mBaiduMap.setMaxAndMinZoomLevel(18, 13);
	// 注册 SDK 广播监听者
	IntentFilter iFilter = new IntentFilter();
	iFilter.addAction(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR);
	iFilter.addAction(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR);
	mReceiver = new BaiduReceiver();
	registerReceiver(mReceiver, iFilter);

	Intent intent = getIntent();
	String type = intent.getStringExtra("type");
	if (type.equals("select")) {// 选择发送位置
		// initTopBarForBoth("位置", R.drawable.btn_login_selector, "发送", new
		// onRightImageButtonClickListener() {
		// @Override
		// public void onClick() {
		// // TODO Auto-generated method stub
		// gotoChatPage();
		// }
		// });
		// mHeaderLayout.getRightImageButton().setEnabled(false);
		initLocClient();
	} else {// 查看当前位置
		// initTopBarForLeft("位置");
		Bundle b = intent.getExtras();
		LatLng latlng = new LatLng(b.getDouble("latitude"), b.getDouble("longtitude"));// 维度在前,经度在后
		mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng(latlng));
		// 显示当前位置图标
		OverlayOptions ooA = new MarkerOptions().position(latlng).icon(bdgeo).zIndex(9);
		mBaiduMap.addOverlay(ooA);
	}

	mSearch = GeoCoder.newInstance();
	mSearch.setOnGetGeoCodeResultListener(this);

}
 
Example #14
Source File: MyApplication.java    From BaiDuMapSelectDemo with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    //在使用SDK各组件之前初始化context信息,传入ApplicationContext
    SDKInitializer.initialize(this);
    //自4.3.0起,百度地图SDK所有接口均支持百度坐标和国测局坐标,用此方法设置您使用的坐标类型.
    //包括BD09LL和GCJ02两种坐标,默认是BD09LL坐标。
    SDKInitializer.setCoordType(CoordType.BD09LL);
}
 
Example #15
Source File: InitApplication.java    From BaiduMap-TrafficAssistant with MIT License 5 votes vote down vote up
@Override
public void onCreate() {
	super.onCreate();
	// 在使用 SDK 各组间之前初始化 context 信息,传入 ApplicationContext
	SDKInitializer.initialize(getApplicationContext());

}
 
Example #16
Source File: BaiduMapActivity.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
public void onReceive(Context context, Intent intent) {
	String s = intent.getAction();
	if (s.equals(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR)) {
		Toast.makeText(instance, "key 验证出错! 请在 AndroidManifest.xml 文件中检查 key 设置", Toast.LENGTH_SHORT).show();
	} else if (s.equals(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR)) {
		Toast.makeText(instance, "网络出错", Toast.LENGTH_SHORT).show();
	}
}
 
Example #17
Source File: BaiduMapPackage.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
@MainThread
protected void init(ReactApplicationContext reactContext) {
    if (Looper.myLooper() == null){
        Looper.prepare();
    }
    SDKInitializer.initialize(reactContext.getApplicationContext());
}
 
Example #18
Source File: MainApplication.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    //初始化百度地图
    //在使用SDK各组件之前初始化context信息,传入ApplicationContext
    //注意该方法要再setContentView方法之前实现
    SDKInitializer.initialize(getApplicationContext());


}
 
Example #19
Source File: EaseBaiduMapActivity.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
public void onReceive(Context context, Intent intent) {
	String s = intent.getAction();
	String st1 = getResources().getString(R.string.Network_error);
	if (s.equals(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR)) {
		
		String st2 = getResources().getString(R.string.please_check);
		Toast.makeText(instance, st2, Toast.LENGTH_SHORT).show();
	} else if (s.equals(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR)) {
		Toast.makeText(instance, st1, Toast.LENGTH_SHORT).show();
	}
}
 
Example #20
Source File: MapService.java    From MapForTour with MIT License 5 votes vote down vote up
@Override
public void onCreate() {
  Log.d("lml", "MapService:onCreate");
  super.onCreate();
  SDKInitializer.initialize(getApplicationContext());
  application = (DeviceMessageApplication) getApplication();
  initializeService();
  mLocationClient.start();
}
 
Example #21
Source File: LocationActivity.java    From Conquer with Apache License 2.0 5 votes vote down vote up
public void onReceive(Context context, Intent intent) {
	String s = intent.getAction();
	if (s.equals(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR)) {
		T.show(context, "key 验证出错! 请在 AndroidManifest.xml 文件中检查 key 设置");
	} else if (s.equals(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR)) {
		T.show(context, "网络出错");
	}
}
 
Example #22
Source File: MyApplication.java    From foodie-app with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    //创建默认的ImageLoader配置参数
    ImageLoaderConfiguration configuration = ImageLoaderConfiguration
            .createDefault(this);

    //Initialize ImageLoader with configuration.
    ImageLoader.getInstance().init(configuration);
    //在使用SDK各组件之前初始化context信息,传入ApplicationContext
    //注意该方法要再setContentView方法之前实现
    SDKInitializer.initialize(getApplicationContext());
}
 
Example #23
Source File: FakeWeiBoActivity.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //在使用SDK各组件之前初始化context信息,传入ApplicationContext
    //注意该方法要再setContentView方法之前实现
    mContext = this;
    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.activity_fake_wei_bo);
    StatusBarUtil.setColor(this, getResources().getColor(R.color.background), 0);
    InitView();
    InitAnim();
    initLocationAndSearch();
    //EventBus
    EventBus.getDefault().register(mContext);
    index = 0;


    if (ContextCompat.checkSelfPermission(mContext,
            Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        //没有定位权限则请求
        ActivityCompat.requestPermissions(this, permissons, MY_PERMISSIONS_REQUEST_LOCATION);

    } else {
        mLocationClient.start();
    }


}
 
Example #24
Source File: DemoApplication.java    From LoveTalkClient with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
	// TODO Auto-generated method stub
	super.onCreate();
	context = this;
	AVOSCloud.initialize(this,
			"h1yik0j4fq0wb7759ruubwdcc7qi4bod880i1joe98jk160s",
			"yl8j5oyb3avv54pbjsl76no4lcnt6lq0z2jngx2dqze4b4h8");
	AVObject.registerSubclass(AddRequest.class);
	SDKInitializer.initialize(this);
	initImageLoader(context);
}
 
Example #25
Source File: LocationActivity.java    From imsdk-android with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.atom_ui_activity_location);
    bundle = getIntent().getExtras();
    bindViews();
    initView();
    ORIGIN_HEIGHT = Utils.dipToPixels(this, 256);
    MAX_HEIGHT = Utils.dipToPixels(this, 360);
    CLIP_WIDTH = (int) (Utils.getScreenWidth(this) * 0.8);
    CLIP_HEIGHT = CLIP_WIDTH * 9 / 16;
}
 
Example #26
Source File: MainActivity.java    From Android-Plugin-Framework with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //appkey是使用插件的packageName注册的
    //sdk的配置信息也在插件中
    SDKInitializer.initialize(getApplication());

    setContentView(R.layout.activity_main);

    mMapView = (MapView) findViewById(R.id.bmapView);
}
 
Example #27
Source File: EaseBaiduMapActivity.java    From Social with Apache License 2.0 5 votes vote down vote up
public void onReceive(Context context, Intent intent) {
	String s = intent.getAction();
	String st1 = getResources().getString(R.string.Network_error);
	if (s.equals(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR)) {
		
		String st2 = getResources().getString(R.string.please_check);
		Toast.makeText(instance, st2, Toast.LENGTH_SHORT).show();
	} else if (s.equals(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR)) {
		Toast.makeText(instance, st1, Toast.LENGTH_SHORT).show();
	}
}
 
Example #28
Source File: AssistantService.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    mAppConfig = (AppConfig) getApplication();
    voiceMediator = VoiceMediator.create(this);
    voiceMediator.setChatStateListener(this);
    //创建数据库相关的表及dao
    DaoManager.create(this);
    mAudioPlayer = LingjuAudioPlayer.create(this);
    mAudioPlayer.setPlayStateListener(this);
    mAudioPlayer.setBluetoothChannelController(bluetoothController);
    chatRobotInited();
    // 初始化百度地图SDK组件
    SDKInitializer.initialize(getApplicationContext());
    BaiduLocateManager.createInstance(getApplicationContext());
    NavigatorService.createInstance(BaiduNaviDao.getInstance(), calculateRouteListener, this);
    //初始化喜马拉雅SDK
    XmlyManager.create(this);
    initProcessor();
    registerReveicer();
    isBlueToothHeadsetConnected();
    if (AppConfig.NewInstallFirstOpen)
        checkAudioRecordPermisssion();
    AppConfig.MainServiceStarted = true;
    //百度地图sdk超级奇葩的bug,在部分android4.+的手机测试发现,如果该方法在BaiduNaviManager.getInstance().init调用之后调用,则该方法无效
    SuggestionSearch.newInstance().requestSuggestion(new SuggestionSearchOption().city("广州市").keyword("天河城"));
    new Timer().schedule(new TimerTask() {
        @Override
        public void run() {
            Looper.prepare();
            EventBus.getDefault().post(new InitNaviManagerEvent());
        }
    }, 3000);
    setAlarm();
}
 
Example #29
Source File: FriendLocationActivity.java    From Social with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SDKInitializer.initialize(MyApplication.mContext);
    setContentView(R.layout.friend_location_activity_layout);

    intentFilter = new IntentFilter("com.allever.social.update_friend_location");
    acceptFriendLocationReceiver = new AcceptFriendLocationReceiver();
    this.registerReceiver(acceptFriendLocationReceiver,intentFilter);

    handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what){
                case OkhttpUtil.MESSAGE_FRIEND_LOCATION_LIST:
                    handleGetFriendLocationList(msg);
                    break;
            }
        }
    };


    ActionBar actionBar = getSupportActionBar();
    actionBar.setLogo(R.mipmap.ic_arrow_back_white_24dp);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle("定位");


    initView();

    getFriendLocationList();
}
 
Example #30
Source File: MainActivity.java    From MoveMapLocation with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //在使用SDK各组件之前初始化context信息,传入ApplicationContext
    //注意该方法要再setContentView方法之前实现
    SDKInitializer.initialize(getApplicationContext());
    //requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);
    initView();
}