AnsweredAssumed Answered

Portal addDoneLoading listener is not being called.

Question asked by salihyalcin89 on Aug 8, 2017
Latest reply on Aug 15, 2017 by ANohe-esristaff

Hi everyone, 

 

We develop an android app that uses Portal for named user licence. When I want to listen portal load event. addDoneLoading listener is not called. Here is my code. 

 

public class MainActivity extends AppCompatActivity {

    private MapView mMapView;
    private ProgressDialog pd;
    Portal portal;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
   

        String theURL = "http://********.ibb.gov.tr";

        //request that the Named User logs in with their credentials
        portal = new Portal(theURL, true);
        portal.setCredential(Utils.getUserCredentialsPortal());
        portal.addDoneLoadingListener(new Runnable() {
            @Override
            public void run() {
                LoadStatus ls = portal.getLoadStatus();
                switch (ls) {
                    case LOADING:
                        Toast.makeText(MainActivity.this, "Load Status 5 !!!  " + portal.getLoadStatus().name(), Toast.LENGTH_SHORT).show();

                        break;
                    case LOADED:

                        LicenseInfo licenseInfo = portal.getPortalInfo().getLicenseInfo();
                        ArcGISRuntimeEnvironment.setLicense(licenseInfo);

                        break;

                    case NOT_LOADED:
                        portal.retryLoadAsync();
                        Toast.makeText(MainActivity.this, "Load Status 7!!!  " + portal.getLoadStatus().name(), Toast.LENGTH_SHORT).show();

                        pd.dismiss();
                        break;

                    case FAILED_TO_LOAD:
                        //portal.retryLoadAsync();
                        Toast.makeText(MainActivity.this, "Load Status 8 !!!  " + portal.getLoadStatus().name(), Toast.LENGTH_SHORT).show();

                        pd.dismiss();
                        break;
                }


            }
        });
        portal.loadAsync();
        mMapView = (MapView) findViewById(R.id.mapView);
        MapViewUtils.setUpBaseMap(mMapView, "https://************/arcgis/rest/services/RehberSB/MapServer", Utils.getUserCredentialsItfaiye());

    }

    @Override
    protected void onPause() {
        super.onPause();
        mMapView.pause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mMapView.resume();
    }
}

 

How could I afford to call addDoneListener ?

 

Thanks for helpings. 

Outcomes