java.lang.IllegalStateException: you have not supplyed the global app context info from SDKInitializ
来源:互联网 发布:网络机顶盒H3芯片 编辑:程序博客网 时间:2024/06/07 03:19
在百度地图api开发中,会遇到:
java.lang.IllegalStateException: you have not supplyed the global app context
info from SDKInitializer.initialize(Context) function
非法状态异常的情况,他说我们没有在SDKInitializer.initialize(Context context)当中提供一个全局应用程序的上下文。
解决方法:
(1)新建一个application文件,例:DemoApplication.java。
(2)在application文件当中添加代码SDKInitializer.initialize(Context context),如图:
(3)在清单文件AndroidManifest.xml中添加application文件,如图:
(4)随便写一个启动百度地图的例子:
/** * 演示MapView的基本用法 */public class BaseMapDemo extends Activity {@SuppressWarnings("unused")private static final String LTAG = BaseMapDemo.class.getSimpleName();private MapView mMapView;private BaiduMap mBaiduMap;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);Intent intent = getIntent();if (intent.hasExtra("x") && intent.hasExtra("y")) {// 当用intent参数时,设置中心点为指定点Bundle b = intent.getExtras();LatLng p = new LatLng(b.getDouble("y"), b.getDouble("x"));mMapView = new MapView(this,new BaiduMapOptions().mapStatus(new MapStatus.Builder().target(p).build()));} else {mMapView = new MapView(this, new BaiduMapOptions());}setContentView(mMapView);mBaiduMap = mMapView.getMap();}@Overrideprotected void onPause() {super.onPause();// activity 暂停时同时暂停地图控件mMapView.onPause();}@Overrideprotected void onResume() {super.onResume();// activity 恢复时同时恢复地图控件mMapView.onResume();}@Overrideprotected void onDestroy() {super.onDestroy();// activity 销毁时同时销毁地图控件mMapView.onDestroy();}}(5)但是别忘了百度地图环境配置,这里就不介绍了,就可以直接运行
0 0
- java.lang.IllegalStateException: you have not supplyed the global app context info from SDKInitializ
- you have not supplyed the global app context info from SDKInitializer.initialize(Context) function
- 百度地图API报错 Caused by: java.lang.IllegalStateException: you have not supplyed the global app context i
- 百度地图API报错 Caused by: java.lang.IllegalStateException: you have not supplyed the global app context i
- 解决Android: java.lang.IllegalStateException: ViewPager does not have
- java.lang.IllegalStateException: Fragment does not have a view
- java.lang.IllegalStateException:Make sure the content of your adapter is not modified from a backgro
- java.lang.IllegalStateException: Could not execute method of the activity
- java.lang.IllegalStateException: Could not execute method of the activity
- java.lang.IllegalStateException: Could not execute method of the activity
- 【Git & GitHub】解决办法:Could not read from remote repository.Please make sure you have the...
- the application you have selected does not exist 或者 套装ID无效 Xcode 提交APP失败
- java.lang.IllegalStateException The specified child already has a parent. You must call removeView()
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView
- java.lang.IllegalStateException The specified child already has a parent. You must call removeView()
- Caused by: java.lang.IllegalStateException: The specified child already has a parent. You
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView(
- Android—java.lang.IllegalStateException: The specified child already has a parent. You must call rem
- XCode单元测试
- 娜样美的观察者模式
- 最小生成树的两种算法
- 1718:Rank
- PHP学习(二)--变量
- java.lang.IllegalStateException: you have not supplyed the global app context info from SDKInitializ
- spoj -705 New Distinct Substrings--后缀数组
- 鸟哥的linux私房菜中推荐的linux学习网站
- OpenGL 多重纹理
- graham扫描法求凸包
- 集群、分布式、负载均衡区别与联系
- 【Android基础】-Activity启动模式详解
- 技术角度wordpress结构优缺点分析
- netty学习(四)----伪异步IO的弊端