Class OfflineRegionSelector


  • public class OfflineRegionSelector
    extends java.lang.Object
    While the offline plugin includes a service for optimally launching an offline download session, the plugin also includes UI components which also assist in providing a way for your app users to select the region in which they'd like to download the region they desire.

    This specific class is used to build an intent which launches the OfflineActivity which provides your users with a way to define the region which they'd like to download. This includes automatically providing the region definition with a name; Whether that's the default name or the name of the region the map's camera position is currently located.

    The provided Intent builder in this class should be built with the options you would like to provide, then passed into the Activity.startActivityForResult(Intent, int) or related methods. Inside the same activity being used to launch this activity you'll need to @Override Activity.onActivityResult(int, int, Intent) and use the provided static methods also provided in this class.

    Note that if you are using this exclusively inside your app with a Mapbox Map not already being used somewhere else, you'll need to provide a Mapbox access token by overriding your applications onCreate method and placing com.mapbox.mapboxsdk.Mapbox#getInstance(Context, String) inside the override method.

    Since:
    0.1.0
    • Method Detail

      • getOfflineDownloadOptions

        public static OfflineDownloadOptions getOfflineDownloadOptions​(android.content.Intent data,
                                                                       byte[] metadata)
        Use this method to take the returning Intent data and construct a OfflineDownloadOptions instance which can be used for starting a new offline region download.
        Parameters:
        data - the Activity.startActivityForResult(Intent, int) which this method should be used in provides the returning intent which should be provided in this param
        metadata - Add additional metadata to the OfflineRegionDefinition, note to make sure not to override the region definition name if you still wish to use it
        Returns:
        a new OfflineDownloadOptions instance which can be used to launch the download service using OfflinePlugin.startDownload(OfflineDownloadOptions)
        Since:
        0.1.0
      • getOfflineDownloadOptions

        public static OfflineDownloadOptions getOfflineDownloadOptions​(android.content.Intent data,
                                                                       NotificationOptions notificationOptions)
        Use this method to take the returning Intent data and construct a OfflineDownloadOptions instance which can be used for starting a new offline region download.
        Parameters:
        data - the Activity.startActivityForResult(Intent, int) which this method should be used in provides the returning intent which should be provided in this param
        notificationOptions - the NotificationOptions object you've constructed to be used when launching the offline region download service.
        Returns:
        a new OfflineDownloadOptions instance which can be used to launch the download service using OfflinePlugin.startDownload(OfflineDownloadOptions)
        Since:
        0.1.0
      • getOfflineDownloadOptions

        public static OfflineDownloadOptions getOfflineDownloadOptions​(android.content.Intent data,
                                                                       NotificationOptions notificationOptions,
                                                                       byte[] metadata)
        Use this method to take the returning Intent data and construct a OfflineDownloadOptions instance which can be used for starting a new offline region download.
        Parameters:
        data - the Activity.startActivityForResult(Intent, int) which this method should be used in provides the returning intent which should be provided in this param
        notificationOptions - the NotificationOptions object you've constructed to be used when launching the offline region download service.
        metadata - Add additional metadata to the OfflineRegionDefinition, note to make sure not to override the region definition name if you still wish to use it
        Returns:
        a new OfflineDownloadOptions instance which can be used to launch the download service using OfflinePlugin.startDownload(OfflineDownloadOptions)
        Since:
        0.1.0
      • getRegionDefinition

        public static com.mapbox.mapboxsdk.offline.OfflineRegionDefinition getRegionDefinition​(android.content.Intent data)
        Returns the OfflineRegionDefinition which was created when the user was inside the OfflineActivity.
        Parameters:
        data - the Activity.startActivityForResult(Intent, int) which this method should be used in provides the returning intent which should be provided in this param
        Returns:
        the OfflineRegionDefinition which was created inside the OfflineActivity
        Since:
        0.1.0
      • getRegionName

        public static java.lang.String getRegionName​(@NonNull
                                                     android.content.Intent data)
        The OfflineActivity class will try to provide a region name which is either the default region naming string or, depending on the map's camera position and where it is positioned over the map.
        Parameters:
        data - the Activity.startActivityForResult(Intent, int) which this method should be used in provides the returning intent which should be provided in this param
        Returns:
        either a string containing the default region name or the actual region name which the map's camera position was last placed over
        Since:
        0.1.0