Try to call retrieveLegendInfo() in separate thread after layer is loaded, like this:
mapView.setOnStatusChangedListener(new OnStatusChangedListener() {
@Override
public void onStatusChanged(Object o, STATUS status) {
if (status == STATUS.LAYER_LOADED) {
if (o instanceof ArcGISDynamicMapServiceLayer) {
//retrieving legend info
new AsyncTask<Void, Void, Void>() {
protected Void doInBackground(Void... voids) {
dynamicLayer.retrieveLegendInfo();
return null;
}
}.execute();
});
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.