首页 / 浏览问题 / 移动GIS / 问题详情
Android使用SceneMapControl绑定VideoEffectView2后再刷新时显示空指针异常
2EXP 2024年12月22日

使用产品:imobile 2024 操作系统:android sdk27 ,指令集armeabi-v7a
数据类型:

问题详细描述:Android使用SceneMapControl绑定VideoEffectView2后再刷新时显示空指针异常
问题重现步骤: 1.在activity_main.xml获取到VideoEffectView2和SceneMapControl的实例;

2、播放视频,打开地图,设置空间位置参数,SceneMapControl使用bindView()方法绑定VideoEffectView2;

3、调用SceneMapControl.refresh() 方法

            sceneMapControl = findViewById(R.id.supermap_scene_map_control);
            videoEffectView = findViewById(R.id.supermap_effect_view);

            sceneMapControl.bindEffectView(videoEffectView);
            sceneMapControl.setCacheFolderPath( sdcard + "/SuperMap/data/Cache_tmp/" , new PrjCoordSys(3857) );
            sceneMapControl.setUseCache(true);

            videoEffectView.setDeviceLocation( new Location( 114.093782007694, 22.5494760274886 , 100  ));
            videoEffectView.getSceneView().getScene().getCamera().setWorldRotation( new Quaternion(30,30,30,30));
            videoEffectView.getSceneView().getScene().getCamera().setWorldPosition( new Vector3( 114 , 22 ,100 ));

            Workspace workspace = new Workspace();
            WorkspaceConnectionInfo info = new WorkspaceConnectionInfo();
            info.setServer(sdcard+"/SuperMap/data/World.smwu");
            info.setType(WorkspaceType.SMWU);
            workspace.open(info);
            //获取地图对象,并打开指定地图
            Map map = sceneMapControl.getMap();
            map.setWorkspace( workspace );
            map.setPrjCoordSys( new PrjCoordSys(3857) );
            map.open("map1");
            map.setScale( 0.0002  );
            map.setCenter( new Point2D(114,22) );
            map.refresh();
            sceneMapControl.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
                @Override
                public void onViewAttachedToWindow(@NonNull View v) {
                    Timer timer = new Timer();
                    timer.schedule(new TimerTask() {
                        @Override
                        public void run() {
                            try {
                                sceneMapControl.refresh( 114.093782007694, 22.5494760274886,"12", false);
                            }catch (Exception e){
                                Log.v("refresh",e.toString());
                            }
                        }
                    } , 3000, 500 );
                }
                @Override
                public void onViewDetachedFromWindow(@NonNull View v) {

                }
            });
            try {
                videoEffectView.getMediaPlayer().setDataSource( sdcard + "/SuperMap/data/Videos/video_60fps.mp4" );
                videoEffectView.getMediaPlayer().prepare();
                videoEffectView.getMediaPlayer().start();

            }catch (Exception e){
                Log.v("media",e.toString());
            }

报错信息:

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
                                                                                                    	at android.graphics.Bitmap.createBitmap(Bitmap.java:905)
                                                                                                    	at android.graphics.Bitmap.createBitmap(Bitmap.java:866)
                                                                                                    	at com.supermap.mapping.BitmapUtils.viewSnapshot(BitmapUtils.java:54)
                                                                                                    	at com.supermap.mapping.MapControl2.outputMap(MapControl2.java:565)
                                                                                                    	at com.supermap.mapping.MapControl.outputMap(MapControl.java:120)
                                                                                                    	at com.supermap.ar.areffect.uav.map.SceneMap.drawMapBlock(SceneMap.java:478)
                                                                                                    	at com.supermap.ar.areffect.uav.map.SceneMap.refresh(SceneMap.java:502)
                                                                                                    	at com.supermap.ar.areffect.uav.map.SceneMap.access$300(SceneMap.java:54)
                                                                                                    	at com.supermap.ar.areffect.uav.map.SceneMap$2.run(SceneMap.java:451)

1个回答

您好,麻烦发下测试demo到邮箱liquanhui@supermap.com,本地测试一下
3,750EXP 2024年12月23日
你好,测试代码及数据已发送,请问有结果了吗
...