Class MobileMapPackage
- java.lang.Object
- 
- com.esri.arcgisruntime.mapping.MobileMapPackage
 
- 
- All Implemented Interfaces:
- Loadable
 
 public final class MobileMapPackage extends Object implements Loadable A mobile map package.Mobile map packages allow you to work with maps on a mobile device. A mobile map package contains all of the files necessary to work with your maps and is stored on a device as either: - A single archive file with an .mmpk extension.
- A directory containing an unpacked mobile map package.
 - ArcGIS Pro (from version 1.3). This version of the ArcGIS Runtime SDK supports any MobileMapPackageup to major version 5. Mobile map packages created with ArcGIS Pro are stored in a file with an .mmpk extension. If created in ArcGIS Pro, mobile map packages may containMobileBasemapLayers.
- ArcGIS Runtime. Use the OfflineMapTask.generateOfflineMap(GenerateOfflineMapParameters, String)method to generate and download a mobile map package on-demand, or useOfflineMapTask.downloadPreplannedOfflineMap(PreplannedMapArea, String)to download a mobile map package already prepared by the map author. Mobile map packages created with theOfflineMapTaskare stored in a directory containing an unpacked mobile map package.
 Itemwith metadata about the package (description, thumbnail, etc.).Mobile map packages created with ArcGIS Pro can also include transportation networks, locators, and links to online services. You can choose whether to use: - A tile package (such as .tpkx or .vptk) or an online basemap as the GeoModel.getBasemap().
- A mobile geodatabase (.geodatabase) or an online feature service as one of the GeoModel.getOperationalLayers().
 Online services (such as traffic or weather) can provide excellent contextual information for your users. If the mobile map package is going to be used in areas of poor connectivity, however, you must ensure that data critical to your workflow is stored locally on the device. Mobile map packages implement the Loadableinterface; you need to load theMobileMapPackagebefore you can access its content. Once loaded you can:- Determine the version of this package using getVersion(). ArcGIS Runtime SDKs currently supports mobile map packages up to and including major version 5. If the package is from an unsupported version, it will fail to load.
- Discover if the mobile map package has expired using getExpiration().
- Access the individual maps and display them in a MapView.
- Programmatically add, modify, and remove layers in the map. Mobile map packages, however, are read-only and these changes to maps or layers are not persisted.
 // create the mobile map package mapPackage = new MobileMapPackage("MyMobileMapPackage.mmpk"); // load the mobile map package asynchronously mapPackage.loadAsync(); // add done listener which will invoke when mobile map package has loaded mapPackage.addDoneLoadingListener(() -> { // check load status and that the mobile map package has maps if(mapPackage.getLoadStatus() == LoadStatus.LOADED && mapPackage.getMaps().size() > 0){ // add the map from the mobile map package to the view mapView.setMap(mapPackage.getMaps().get(0)); });- Since:
- 100.0.0
- See Also:
- ArcGISMap,- Loadable,- LocatorTask,- TransportationNetworkDataset
 
- 
- 
Constructor SummaryConstructors Constructor Description MobileMapPackage(String path)Creates a new MobileMapPackage from the .mmpk file or an unpacked mobile map package at the given path.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddDoneLoadingListener(Runnable listener)Adds a listener to the loadable resource that is invoked when loading has completed.voidaddLoadStatusChangedListener(LoadStatusChangedListener listener)Adds aLoadStatusChangedListenerto the loadable resource that is invoked whenever the load status changes.voidcancelLoad()Cancels loading metadata for the object.voidclose()Closes a mobile map package and frees file locks on the underlying .mmpk file or directory.ExpirationgetExpiration()Expiration details for this mobile map package, if provided.ItemgetItem()The mobile map package'sItemdescribing metadata about the mobile map package.ArcGISRuntimeExceptiongetLoadError()Returns the most recent error that was encountered when the loadable resource transitioned to theLoadStatus.FAILED_TO_LOADstate, either due to calling theLoadable.loadAsync()orLoadable.retryLoadAsync()method.LoadStatusgetLoadStatus()Returns theLoadStatusof the loadable resource.LocatorTaskgetLocatorTask()ALocatorTaskfrom the mobile map package.List<ArcGISMap>getMaps()An unmodifiable list ofArcGISMapobjects from theMobileMapPackage.StringgetPath()Gets the path to the mobile map package.StringgetVersion()The mobile map package's version.static ListenableFuture<Boolean>isDirectReadSupportedAsync(String path)Deprecated.As of 100.7.0, no replacement.voidloadAsync()Loads the metadata of the loadable resource asynchronously.booleanremoveDoneLoadingListener(Runnable listener)Removes a done loading listener from the loadable resource.booleanremoveLoadStatusChangedListener(LoadStatusChangedListener listener)Removes aLoadStatusChangedListenerfrom the loadable resource.voidretryLoadAsync()Loads or retries loading metadata for the object asynchronously.static ListenableFuture<Void>unpackAsync(String path, String destinationFolder)Unpacks a mobile map package file (.mmpk) to an output directory.
 
- 
- 
- 
Constructor Detail- 
MobileMapPackagepublic MobileMapPackage(String path) Creates a new MobileMapPackage from the .mmpk file or an unpacked mobile map package at the given path. An unpacked mobile map package is created when a map is taken offline byOfflineMapTask.generateOfflineMap(GenerateOfflineMapParameters, String).Call loadAsync before accessing the package's contents. - Parameters:
- path- the path to a .mmpk file or a folder containing an exploded mobile map package
- Throws:
- IllegalArgumentException- if path is null or empty
- Since:
- 100.0.0
 
 
- 
 - 
Method Detail- 
getMapspublic List<ArcGISMap> getMaps() An unmodifiable list ofArcGISMapobjects from theMobileMapPackage.To use the maps in a MobileMapPackage, you first need to load the package. If the mobile map package was created with ArcGIS Pro, the maps are presented in the same order in which they were packaged. Mobile map packages created with theOfflineMapTaskwill only contain one map.If you display the map by setting the map on a MapView, the map will automatically load. If you only need to access the map's content or metadata, you will need to load it by callingGeoModel.loadAsync().If the package is not loaded, an empty collection is returned. - Returns:
- a list of maps in the mobile map package
- Since:
- 100.0.0
 
 - 
getItempublic Item getItem() The mobile map package'sItemdescribing metadata about the mobile map package. The item includes the metadata about the mobile map package, such as:- Title
- Snippet (summary)
- Description
- Tags
- Thumbnail
 OfflineMapTask, the metadata was provided by the originating web map.A package's item will be an instance of a LocalItem.- Returns:
- Item
- Since:
- 100.0.0
 
 - 
getPathpublic String getPath() Gets the path to the mobile map package.The path can refer to a file with an .mmpk extension or a directory containing an unpacked mobile map package. - Returns:
- path to the .mmpk file or exploded mobile map package
- Since:
- 100.0.0
- See Also:
- MobileMapPackage(String)
 
 - 
getVersionpublic String getVersion() The mobile map package's version.The mobile map package version is set when the package is authored in ArcGIS Pro or when it is generated by the OfflineMapTask.This property will be populated when you attempt to load the package. The version property will always be populated for you to examine, even if the package is an unsupported version. ArcGIS Runtime SDKs currently support mobile map packages up to and including major version 5. You may wish to check the version property before trying to access specific functionality. For example: - Expiration details are only available from mobile map package version 3.1 onwards.
- Links to online services are only available from mobile map package version 4.0 onwards.
 - Returns:
- the mobile map package version
- Since:
- 100.0.0
 
 - 
getLocatorTaskpublic LocatorTask getLocatorTask() ALocatorTaskfrom the mobile map package.Use this task to geocode and reverse-geocode addresses and places. There is only one LocatorTaskin each mobile map package but it can be used by all maps.Returns null if there is no LocatorTaskin the package or the package is not loaded.- Returns:
- the mobile map package's locator task
- Since:
- 100.0.0
- See Also:
- LocatorTask
 
 - 
getExpirationpublic Expiration getExpiration() Expiration details for this mobile map package, if provided.Expiration details provide: - The package’s expiration date and time.
- If the maps can be accessed after expiration.
- Any messages relevant for the user.
 OfflineMapTaskdo not support expiration.By publishing a package with expiration details, the author can control the experience an end-user has when they try to access information that is no longer valid. For example, for time limited data (such as major sporting events), the author can ensure that the data cannot be accessed after the expiry date. During package loading, the ArcGIS Runtime will determine whether the mobile map package was authored with expiration. If so, then this property will be populated. If the package has expired and was authored as ExpirationType.PREVENT_EXPIRED_ACCESS, loading will fail and you will not be able to access the maps. The expiration details will be accessible for you to examine and/or communicate to the user.- Returns:
- the expiration details for this mobile map package, or null if the package is not loaded or no expiration date has been set
- Since:
- 100.5.0
- See Also:
- Expiration
 
 - 
closepublic void close() Closes a mobile map package and frees file locks on the underlying .mmpk file or directory.All references to mobile map package data (maps, layers, tables, networks, locators, etc.) should be released before closing the package. If active references to mobile map package data exist, this method will still close the package, but subsequent rendering and data access methods will fail. Results of accessing mobile map package data after close are undefined. After closing a mobile map package, the underlying .mmpk file or directory can be moved or deleted. Closing a mobile map package is not necessary if the package has not been loaded. - Since:
- 100.6.0
- See Also:
- MobileScenePackage.close(),- Geodatabase.close()
 
 - 
isDirectReadSupportedAsync@Deprecated public static ListenableFuture<Boolean> isDirectReadSupportedAsync(String path) Deprecated.As of 100.7.0, no replacement. This method is no longer required, since the result is always true. It can be removed from calling code, including any subsequent use ofunpackAsync(String, String).Checks if a mobile map package file (.mmpk) can be read directly without requiring to be unpacked. Always returns true after deprecation in version 100.7.Prior to version 100.7 some data formats could only be accessed if they were present on disk, for example, RasterLayer. In these situations, this method would return false and you would need to unpack the package to access the data.From version 100.7 and onwards this limitation has been removed, allowing the data to be read directly from the mobile map package. This method always returns a result of true. - Parameters:
- path- the path to a .mmpk file
- Returns:
- a ListenableFuture. Add a listener to this to know when the result is ready. The result of the future indicates if direct read is supported or not.
- Throws:
- IllegalArgumentException- if path is null or empty
- Since:
- 100.2.1
 
 - 
unpackAsyncpublic static ListenableFuture<Void> unpackAsync(String path, String destinationFolder) Unpacks a mobile map package file (.mmpk) to an output directory.If the last level of the output directory is not present, it will be created as part of the unpack task. The returned future can be canceled with Future.cancel(boolean)to abort the unpack.The unpack task writes the full content of the mobile map package to the output directory. Care should be taken on devices with limited storage space, especially if the original package is very large. After unpacking, you can remove the original .mmpk file from the device. Note that unpacking will fail if the package is expired and was authored as ExpirationType.PREVENT_EXPIRED_ACCESS.- Parameters:
- path- the path to a .mmpk file
- destinationFolder- the folder to place the unpacked .mmpk
- Returns:
- a ListenableFuture. Add a listener to this to know when the unpack is done.
- Throws:
- IllegalArgumentException- if path is null or empty
- IllegalArgumentException- if destinationFolder is null or empty
- Since:
- 100.2.1
 
 - 
getLoadStatuspublic LoadStatus getLoadStatus() Description copied from interface:LoadableReturns theLoadStatusof the loadable resource.- Specified by:
- getLoadStatusin interface- Loadable
- Returns:
- the LoadStatus of the loadable resource
 
 - 
getLoadErrorpublic ArcGISRuntimeException getLoadError() Description copied from interface:LoadableReturns the most recent error that was encountered when the loadable resource transitioned to theLoadStatus.FAILED_TO_LOADstate, either due to calling theLoadable.loadAsync()orLoadable.retryLoadAsync()method.If the resource subsequently transitions to LoadStatus.LOADED(for example, if a call toretryLoadAsynccompletes successfully) the error is cleared out.- Specified by:
- getLoadErrorin interface- Loadable
- Returns:
- the most recent error that was encountered when the loadable resource transitioned to the
         LoadStatus.FAILED_TO_LOADstate.
 
 - 
cancelLoadpublic void cancelLoad() Description copied from interface:LoadableCancels loading metadata for the object.Cancels loading the metadata if the object is loading, and always invokes the done loading listener. A load operation that is in progress ( LoadStatus.LOADINGstate) can be cancelled by calling this method and the resource will transition fromLoadStatus.LOADINGtoLoadStatus.FAILED_TO_LOADstate. If the load operation was successfully cancelled, a CancellationException will be returned fromLoadable.getLoadError().Cancellation should be used carefully because all enqueued done loading listeners for that resource instance will get invoked with an error stating that the operation was cancelled. Thus, one component in the application can cancel the load operation initiated by other components. This method does nothing if the resource is not in LoadStatus.LOADINGstate.- Specified by:
- cancelLoadin interface- Loadable
 
 - 
loadAsyncpublic void loadAsync() Description copied from interface:LoadableLoads the metadata of the loadable resource asynchronously.The load status changes from LoadStatus.NOT_LOADEDtoLoadStatus.LOADING. A listener can be added viaLoadable.addDoneLoadingListener(java.lang.Runnable)that is invoked upon completion of the asynchronous load operation.If the load operation completes successfully, the load status will be LoadStatus.LOADED, which means the resource has loaded its metadata.If the load operation failed, the load status will be LoadStatus.FAILED_TO_LOADand the error can be retrieved by callingLoadable.getLoadError().This method can be called concurrently and repeatedly, but only one attempt is ever made to perform the load operation. If a load operation is already in progress ( LoadStatus.LOADINGstate) whenloadAsyncis called, it simply piggy-backs on the outstanding operation and the done loading listener added to the loadable resource is enqueued to be invoked when that operation completes. If the operation has already completed (LoadStatus.LOADEDorLoadStatus.FAILED_TO_LOADstate) whenloadAsyncis called, the done loading listener is immediately invoked when added to the loadable resource.If a loadable resource has failed to load, calling loadAsyncon it subsequently will not change its state. The done loading listener will be invoked immediately when added to the loadable resource. In order to retry loading the resource,Loadable.retryLoadAsync()needs to be used.A load operation that is in progress ( LoadStatus.LOADINGstate) can be cancelled by callingLoadable.cancelLoad().
 - 
retryLoadAsyncpublic void retryLoadAsync() Description copied from interface:LoadableLoads or retries loading metadata for the object asynchronously.Will retry loading the metadata if the object's load status is LoadStatus.FAILED_TO_LOAD. Will load the object if it is not loaded. Will not retry to load the object if the object is loaded.For more details on the load process see Loadable.loadAsync().- Specified by:
- retryLoadAsyncin interface- Loadable
 
 - 
addDoneLoadingListenerpublic void addDoneLoadingListener(Runnable listener) Description copied from interface:LoadableAdds a listener to the loadable resource that is invoked when loading has completed.The listener may be added at any point, whether the loadable resource has already completed loading or not. - For resources that are not loaded when the listener is added (LoadStatus is NOT_LOADED or LOADING): When the resource completes loading, the listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- For resources that are already loaded when the listener is added (LoadStatus is LOADED or FAILED_TO_LOAD): The listener will be called immediately, on the current thread.
 Alternatively, to be notified when there is any change in the load status, use the Loadable.addLoadStatusChangedListener(LoadStatusChangedListener)method instead.- Specified by:
- addDoneLoadingListenerin interface- Loadable
- Parameters:
- listener- a Runnable that is invoked upon completion of the load operation
 
 - 
removeDoneLoadingListenerpublic boolean removeDoneLoadingListener(Runnable listener) Description copied from interface:LoadableRemoves a done loading listener from the loadable resource.- Specified by:
- removeDoneLoadingListenerin interface- Loadable
- Parameters:
- listener- the listener to be removed
- Returns:
- true if the listener was removed, otherwise false
 
 - 
addLoadStatusChangedListenerpublic void addLoadStatusChangedListener(LoadStatusChangedListener listener) Description copied from interface:LoadableAdds aLoadStatusChangedListenerto the loadable resource that is invoked whenever the load status changes.Adding this listener on the UI thread will cause it to be invoked on the UI thread, otherwise it is not guaranteed on which thread the listener is invoked. The listener will not be called if added to a loadable resource that has already completed loading. To be notified when a loadable resource has completed loading, including if the resource is already loaded when the listener is added, use the Loadable.addDoneLoadingListener(Runnable)method.- Specified by:
- addLoadStatusChangedListenerin interface- Loadable
- Parameters:
- listener- the- LoadStatusChangedListenerto be added
 
 - 
removeLoadStatusChangedListenerpublic boolean removeLoadStatusChangedListener(LoadStatusChangedListener listener) Description copied from interface:LoadableRemoves aLoadStatusChangedListenerfrom the loadable resource.- Specified by:
- removeLoadStatusChangedListenerin interface- Loadable
- Parameters:
- listener- the- LoadStatusChangedListenerto be removed
- Returns:
- true if the listener was removed, otherwise false
 
 
- 
 
-