HERE Android SDK Developer's Guide

Embedding the Map Service

Map Service is an Android service that facilitates the use of a shared disk cache among applications that use the HERE SDK. This service must be embedded and deployed with your HERE-enabled application; otherwise, the MISSING_SERVICE error code is returned via the onEngineInitializationCompleted() callback.

To embed Map Service, add the following lines inside the <application></application> section in your AndroidManifest.xml file:
<service
  android:name="com.here.android.mpa.service.MapService"
  android:label="HereMapService"
  android:process="global.Here.Map.Service.v3"
  android:exported="true" >
  <intent-filter>
    <action android:name="com.here.android.mpa.service.MapService.v3" >
    </action>
  </intent-filter>
</service>

Incompatibility with Older Versions

Starting in v3.4, the HERE SDK is no longer compatible with pre-3.4 versions of the HERE SDK disk cache. Map data downloaded on pre-3.4 versions of the HERE SDK cannot be used on v3.4 or later.

If your app uses the shared disk cache settings as described above, be aware of the following:
  • The required <service>...</service> snippet, as described in the previous section, has changed.
  • When your users update their pre-3.4 HERE SDK apps to a newer version, their previously-downloaded data will be unavailable. This occurs whether the app was automatically or manually updated.
  • In the case where a user has multiple HERE SDK apps on their system, pre-3.4 apps share one cache, while post-3.4 apps share another.
If your app uses the isolated disk cache setting as described in the next section, be aware of the following:
  • When your users update their pre-3.4 HERE SDK apps to a newer version, their previously-downloaded data will be unavailable. This occurs whether the app was automatically or manually updated.
  • You can avoid this issue by upgrading the pre-3.4 cache using the DiskCacheUtility.migrate(String sourcePath, String destPath) method. This method takes the same path value as setIsolatedDiskCacheRootPath(String, String), and it must be run before MapEngine is initialized for the first time.
    Note: migrate(String, String) is marked as deprecated because it is offered temporarily to assist with the transition. It will be removed in a future release.

Using an Isolated Map Disk Cache with the Map Service

The HERE SDK supports an isolated disk cache. This allows you to set the disk cache to another location, such as an SD Card.

Note:
  • This feature is considered experimental, and migrating the disk cache contents from one location to another is not supported. If you are using an SD card, ensure the SD card is always present to avoid any unexpected behavior.
  • You should only delete the map data cache when the app is in its early start-up stages, before any HERE SDK calls. Otherwise, map data corruption and unexpected app errors can occur.
  • If you plan to support changing the storage location, such as switching between internal storage and an SD card, be aware that this requires an app restart, as the storage location switch must be done before initializing MapEngine or MapFragment. Also, your manifest entry for the MapService must not contain the process attribute, so that the MapService runs in the same process as your app. Doing so ensures it that the service is shut down properly when the app restarts (for example, using System.exit()), and that the disk cache location change can take effect.

The first step to use an isolated disk cache is to edit the AndroidManifest.xml with the following, providing the service label and intent name with your custom values.

<service
  android:name="com.here.android.mpa.service.MapService"
  android:label="{YOUR_LABEL_NAME}"
  android:exported="false" >
  <intent-filter>
    <action android:name="{YOUR_INTENT_NAME}" >
    </action>
  </intent-filter>
</service>
Note: Always provide custom values for {YOUR_LABEL_NAME} and {YOUR_INTENT_NAME} when you are using an isolated disk cache. Do not reuse the HERE SDK defaults.

After editing AndroidManifest.xml, add a call to MapSettings.setIsolatedDiskCacheRootPath(String path, String intent) with the desired cache location and the custom intent name. This call should occur before MapEngine initialization. For example, if you are modifying the application from the sample tutorial app, you can add the call in the BasicMapActivity.java file before mapFragment.init().

public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  // Search for the map fragment to finish setup by calling init().
  mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.mapfragment);
  boolean success = com.here.android.mpa.common.MapSettings.setIsolatedDiskCacheRootPath(
    "/sdcard/foo/myservice", "{YOUR_INTENT_NAME}");

  if (!success) {
    // Setting the isolated disk cache was not successful, please check if the path is valid and
    // ensure that it does not match the default location
    // (getExternalStorageDirectory()/.here-maps).
    // Also, ensure the provided intent name does not match the default intent name.
  } else {
    mapFragment.init(new OnEngineInitListener() {
    ...
}

You cannot use this account to purchase a commercial plan on Developer Portal, as it is already associated to plans with different payment methods.

To purchase a commercial plan on Developer Portal, please register for or sign in with a different HERE Account.

Something took longer than expected.

The project should be available soon under your projects page.

Sorry, our services are not available in this region.

Something seems to have gone wrong. Please try again later.

We've detected that your account is set to Australian Dollars (AUD).
Unfortunately, we do not offer checkouts in AUD anymore.
You can continue using your current plan as normal, but to subscribe to one of our new plans,
please register for a new HERE account or contact us for billing questions on selfservesupport@here.com.