Hi All, I am very new in ArcGIS Runtime SDK for Android 100.2.0. Android studio 3 platform is used to load a local shapefile in my android mobile,but nothing shown. MainActivity.java as below. Any idea?
package com.example.interfly.displaymap;
import android.graphics.Color;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.esri.arcgisruntime.data.ShapefileFeatureTable;
import com.esri.arcgisruntime.layers.FeatureLayer;
import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.LayerList;
import com.esri.arcgisruntime.mapping.view.MapView;
import com.esri.arcgisruntime.symbology.Renderer;
import com.esri.arcgisruntime.symbology.SimpleFillSymbol;
import com.esri.arcgisruntime.symbology.SimpleLineSymbol;
import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol;
import com.esri.arcgisruntime.symbology.SimpleRenderer;
import com.esri.arcgisruntime.symbology.Symbol;
import java.io.File;
import static android.media.MediaCodec.MetricsConstants.MODE;
public class MainActivity extends AppCompatActivity {
private MapView mMapView;
@Override
protected void onPause(){
mMapView.pause();
super.onPause();
}
@Override
protected void onResume(){
super.onResume();
mMapView.resume();
}
public String getSDPath(){
File sdDir = null;
boolean sdCardExist = Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED); // sd card exist?
if (sdCardExist)
{
sdDir = Environment.getExternalStorageDirectory();// get root dir.
}
return sdDir.toString();
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mMapView = findViewById(R.id.mapView);
ArcGISMap map = new ArcGISMap();
//ArcGISMap map = new ArcGISMap(Basemap.createStreetsVector());
String shpPath=getSDPath()+ "/arcgis/shapefile/GeoNet_cmt.shp";
ShapefileFeatureTable shapefileFeatureTable_geo = new ShapefileFeatureTable(shpPath);
FeatureLayer featureLayer = new FeatureLayer(shapefileFeatureTable_geo);
featureLayer.setRenderer(new SimpleRenderer(new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 10)));
map.getOperationalLayers().add(featureLayer);
mMapView.setMap(map);
}
}