Hi,
I'm trying to follow this sample code https://developers.arcgis.com/net/latest/android/sample-code/featurelayergeopackage.htm#GUID-D49CFDE... but in JAVA, using this file https://www.arcgis.com/home/item.html?id=68ec42517cdd439e81b036210483e8e7.
When I try to get the feature layer (line 51) the list is empty. Did I do something wrong?
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.LinearLayout;
import com.esri.arcgisruntime.data.FeatureTable;
import com.esri.arcgisruntime.data.GeoPackage;
import com.esri.arcgisruntime.layers.FeatureLayer;
import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.view.MapView;
import java.io.File;
public class MainActivity extends AppCompatActivity {
private MapView mapView;
private final String filename = "AuroraCO.gpkg";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
createLayout();
initialize();
}
private void createLayout() {
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setOrientation(LinearLayout.VERTICAL);
mapView = new MapView(this);
linearLayout.addView(mapView);
setContentView(linearLayout);
}
private void initialize() {
new AsyncTask<Void, Void, Void>() {
@Override
protected void onPreExecute() {
mapView.setMap(new ArcGISMap(Basemap.Type.LIGHT_GRAY_CANVAS, 39.7294, -104.8319, 9));
}
@Override
protected Void doInBackground(Void... voids) {
String geoPackagePath = getGeoPackagePath();
final GeoPackage geoPackage = new GeoPackage(geoPackagePath);
geoPackage.addDoneLoadingListener(new Runnable() {
@Override
public void run() {
FeatureTable featureTable = geoPackage.getGeoPackageFeatureTables().get(0);
final FeatureLayer featureLayer = new FeatureLayer(featureTable);
featureLayer.addDoneLoadingListener(new Runnable() {
@Override
public void run() {
mapView.getMap().getOperationalLayers().add(featureLayer);
}
});
featureLayer.loadAsync();
}
});
geoPackage.loadAsync();
return null;
}
}.execute();
}
private String getGeoPackagePath() {
String folder = "/storage/emulated/0/labs/";
File file = new File(folder + filename);
if(!file.exists()){
return "";
}
return file.getPath();
}
}