代码完全参考SuperMap iMobile 11i(2022) Beta for Android Guide.pdf中给出的代码文件
package com.example.supermap;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.supermap.data.Environment;
import com.supermap.data.Workspace;
import com.supermap.data.WorkspaceConnectionInfo;
import com.supermap.data.WorkspaceType;
import com.supermap.mapping.MapControl;
import com.supermap.mapping.MapView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapControl mapControl = null;
String rootPath = android.os.Environment.getExternalStorageDirectory().getAbsolutePath();
//设置许可文件路径(默认路径“/SuperMap/license/”)
Environment.setLicensePath(rootPath + "/SuperMap/license/");
//组件功能必须在Environment初始化之后才能调用
Environment.initialization(this);
setContentView(R.layout.activity_main);
//打开工作空间
Workspace m_workspace = new Workspace();
WorkspaceConnectionInfo info = new WorkspaceConnectionInfo();
info.setServer(rootPath + "/SampleData/GeometryInfo/World.smwu");
info.setType(WorkspaceType.SMWU);
m_workspace.open(info);
//将地图显示控件和工作空间关联
MapView m_mapView = findViewById(R.id.Map_view);
mapControl = m_mapView.getMapControl();
mapControl.getMap().setWorkspace(m_workspace);
//打开工作空间中的第二幅地图
String mapName = m_workspace.getMaps().get(1);
mapControl.getMap().open(mapName);
mapControl.getMap().refresh();
}
}
打开雷电模拟器后,运行。App直接崩溃,错误信息: Caused by: java.lang.IllegalArgumentException: /storage/emulated/0/SuperMap/license/ is not a correct directory
曾经尝试使用cmd传入数据,但是没成功。尝试的方法如下:
cmd命令行报错:
请问该如何解决并把数据传入呢?把数据和许可发送给模拟器呢?从而可以运行起来?