Problem in Open MMPK file offline on Android Mobile Phone

1463
6
05-22-2017 07:53 PM
DeepakMaheshwari
New Contributor

I am learning ArcGIS runtime SDK for Android Devlabs' Tutorial. While completing the tutorial entitled "Display a Map While Offline", I did the same as tutorial says i.e. I created "devlabs-package.mmpk" file using arcgis pro and I saved this .mmpk file on my android phone's SD card. Though, When I start the project using Android Studio my mobile shows only online basemap (street basemap) not the map that I created for .mmpk file. I used the code as written in the devlabs tutorial. the snapshot of the code is attached herewith-

Kindly do help me. I am new and know little about the coding.

0 Kudos
6 Replies
AlexanderNohe1
Occasional Contributor III

Did you request runtime permissions?

Requesting Permissions | Android Developers 

Can you place a link to the sample you used?

0 Kudos
DeepakMaheshwari
New Contributor

Respected Alexander Nohe

I added the following two types of permission in the app > manifests > AndroidManifest.xml-
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />

I used the same "devlabs-package.mmpk file that I created in ArcGIS Pro using the data as described in the dev labs tutorials.
Need your help If I have missed something.

0 Kudos
AlexanderNohe1
Occasional Contributor III

So if you are targeting any runtime later than API level 22 for Android, you need to request permissions at runtime for what is considered a "dangerous" permission.

This stack overflow post should help you request a permission at runtime:

Android marshmallow request permission? - Stack Overflow 

0 Kudos
DeepakMaheshwari
New Contributor

Respected Alexander Nohe,

I did what you suggested but I could not open mmpk file offline on my android phone. Would you please guide me in this regard. I saved my .mmpk file on my sdcard in the "myfolder/samples/MapPackage/devlabs-package.mmpk". According to you what shold be the file path code. Kindly help me.

0 Kudos
AlexanderNohe1
Occasional Contributor III

Environment.getExternalStorageDirectory() is one trick that comes to mind.  These documents may help you:

Environment | Android Developers 

android - Find an external SD card location - Stack Overflow 

I would also encourage you to implement a file picker so the SD file card path does not have to be exact.  One file picker that comes to mind is this one:

GitHub - spacecowboy/NoNonsense-FilePicker: A file/directory-picker for android. Implemented as a li... 

There are many more open source file pickers out there which may be better suited for your needs.

Use that library at your own risk.  Esri has not evaluated nor tested this file picker and cannot guarantee the safety or security of this library. 

0 Kudos
DeepakMaheshwari
New Contributor

Respected Alexander Nohe

The link of the sample I used is

https://developers.arcgis.com/labs/data/devlabs-package.mmpk 

0 Kudos