protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.bus); this.app = ((MyApplication)getApplication()); if (this.app.mBMapMan == null) { this.app.mBMapMan = new BMapManager(getApplication()); this.app.mBMapMan.init(this.app.mStrKey, new MyApplication.MyGeneralListener()); } this.app.mBMapMan.start(); this.db = new DatabaseHelper(this); findView(); initView(); local(); this.mkSearch = new MKSearch(); this.mkSearch.init(this.app.mBMapMan, new MKSearchListener() { @Override public void onGetAddrResult(MKAddrInfo arg0, int arg1) { // TODO Auto-generated method stub } @Override public void onGetBusDetailResult(MKBusLineResult arg0, int arg1) { // TODO Auto-generated method stub } @Override public void onGetDrivingRouteResult(MKDrivingRouteResult arg0, int arg1) { // TODO Auto-generated method stub } @Override public void onGetPoiDetailSearchResult(int arg0, int arg1) { // TODO Auto-generated method stub } @Override public void onGetPoiResult(MKPoiResult arg0, int arg1, int arg2) { // TODO Auto-generated method stub } @Override public void onGetRGCShareUrlResult(String arg0, int arg1) { // TODO Auto-generated method stub } @Override public void onGetSuggestionResult(MKSuggestionResult arg0, int arg1) { // TODO Auto-generated method stub } @Override public void onGetTransitRouteResult(MKTransitRouteResult arg0, int arg1) { // TODO Auto-generated method stub } @Override public void onGetWalkingRouteResult(MKWalkingRouteResult arg0, int arg1) { // TODO Auto-generated method stub } }); }
package com.zjgbus.util.widget; import android.app.Application; import android.util.Log; import android.widget.Toast; import com.baidu.mapapi.BMapManager; import com.baidu.mapapi.MKGeneralListener; import java.util.List; public class MyApplication extends Application { static MyApplication mDemoApp; public BMapManager mBMapMan = null; public String mStrKey = "33ADDE9544E7F53D9AAEF06F328A75C21E79EA8A"; boolean m_bKeyRight = true; // 授权Key正确,验证通过 public void onCreate() { Log.v("BMapApiDemoApp", "onCreate"); mDemoApp = this; mBMapMan = new BMapManager(this); boolean isSuccess = mBMapMan.init(this.mStrKey, new MyGeneralListener()); // 初始化地图sdk成功,设置定位监听时间 if (isSuccess) { mBMapMan.getLocationManager().setNotifyInternal(10, 5); } else { // 地图sdk初始化失败,不能使用sdk } super.onCreate(); } @Override //建议在您app的退出之前调用mapadpi的destroy()函数,避免重复初始化带来的时间消耗 public void onTerminate() { // TODO Auto-generated method stub if (mBMapMan != null) { mBMapMan.destroy(); mBMapMan = null; } super.onTerminate(); } public static class MyGeneralListener implements MKGeneralListener { public void onGetNetworkState(int paramInt) { Log.d("MyGeneralListener", "onGetNetworkState error is " + paramInt); Toast.makeText(MyApplication.mDemoApp.getApplicationContext(), "您的网络出错啦!", 1).show(); } public void onGetPermissionState(int paramInt) { Log.d("MyGeneralListener", "onGetPermissionState error is " + paramInt); if (paramInt == 300) { Toast.makeText(MyApplication.mDemoApp.getApplicationContext(), "请在BMapApiDemoApp.java文件输入正确的授权Key!", 1).show(); MyApplication.mDemoApp.m_bKeyRight = false; } } } }
最新发现配置文件里的
竟然报333333333333333,难道SDK初始化也失败了。。。
publicvoidonCreate(){mDemoApp=this;mBMapMan=newBMapManager(this);booleanisSuccess=mBMapMan.init(this.mStrKey,newMyGeneralListener());//初始化地图sdk成功,设置定位监听时间if(isSuccess){Log.v("BMapApiDemoApp","onCreate");System.out.println("222222222222222222222");mBMapMan.getLocationManager().setNotifyInternal(10,5);}else{//地图sdk初始化失败,不能使用sdkSystem.out.println("3333333333333333333333333333");}super.onCreate();} 你要在实现那个接口里修改方法:你看看这里: http://blog.csdn.net/OnlyOneCoder/article/details/8469926改这个: onGetPoiResult 还有 onGetPoiDetailSearchResult这个。。。试试看看呢什么意思,小弟不明白目前发现mBMapMan.init(this.mStrKey,newMyGeneralListener());这个返回竟然也是flase你看看是不是你授权KEY有问题哦版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。