Accessing Scene Layer Package(slpk)

212
2
08-02-2018 02:38 AM
Siva_SankaraReddy_T
New Contributor II

Hi,

I tried to access slpk file from device using ArcGISSceneLayer.  But i unable to access. please help me.

Tags (1)
0 Kudos
2 Replies
ShellyGill1
Esri Contributor

Hi Shiva,

I would guess that you might be missing the Android Framework permissions code that allow an app to access local storage, but without more details of the error you're seeing its difficult to be sure. There's no sample currently that is using an .slpk file, but there are a lot of samples that show accessing local storage and include the permissions code that you should have - you could check the arcgis-runtime-samples-android/java/open-mobile-mappackage at master · Esri/arcgis-runtime-samples-a...  sample for an example of this code, and also refer to the Android Framework doc at  Permissions overview  |  Android Developers .   If that's not the problem then post back more details about your error.

Shelly

XiangNingJiao1
New Contributor II

Hi, Shiva,

I have meet a similar problem recently, and I found a solution for this. I agree with Shelly Gill‌’s point of view, and you maybe meet the permissions issues of over Android  6.0. You should get dynamic permissions in you code, like the following code.

private void InitializePermissions() {
    if (!CheckPermission()) {
        RequirePermission();
    }
}
private boolean CheckPermission() {
    for (String permission : PERMISSIONS) {
        if (ActivityCompat.checkSelfPermission(this, permission) !=
                PackageManager.PERMISSION_GRANTED) {
            return false;
        }
    }

    return true;
}
private void RequirePermission() {
    ActivityCompat.requestPermissions(this, PERMISSIONS, 1);
}

The PERMISSIONS is

private final String[] PERMISSIONS = new String[] {
        Manifest.permission.READ_EXTERNAL_STORAGE,
        Manifest.permission.WRITE_EXTERNAL_STORAGE
};

And your onCreate function maybe like:


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

    InitializePermissions();
    /* Write you code there */
}

Hopt to help you.

0 Kudos