use of com.here.android.mpa.common.ApplicationContext in project here-android-sdk-examples by heremaps.
the class MapFragmentView method initMapFragment.
private void initMapFragment() {
m_mapFragment = getMapFragment();
// This will use external storage to save map cache data, it is also possible to set
// private app's path
String path = new File(m_activity.getExternalFilesDir(null), ".here-map-data").getAbsolutePath();
// This method will throw IllegalArgumentException if provided path is not writable
com.here.android.mpa.common.MapSettings.setDiskCacheRootPath(path);
if (m_mapFragment != null) {
ApplicationContext applicationContext = new ApplicationContext(m_activity);
applicationContext.setDiskCacheSize(CACHE_SIZE);
/* Initialize the AndroidXMapFragment, results will be given via the called back. */
m_mapFragment.init(applicationContext, new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(Error error) {
if (error == OnEngineInitListener.Error.NONE) {
m_map = m_mapFragment.getMap();
if (m_progressBar.getVisibility() == View.VISIBLE) {
boolean b = true;
}
setOptionType(OptionType.MAP_BOUNDING_BOX);
} else {
Toast.makeText(m_activity, m_activity.getText(R.string.error_occurred) + error.toString(), Toast.LENGTH_SHORT).show();
}
}
});
}
}
use of com.here.android.mpa.common.ApplicationContext in project here-android-sdk-examples by heremaps.
the class PositioningService method initMapEngine.
/**
* Initialize HERE SDK map engine.
*/
private void initMapEngine() {
if (MapEngine.isInitialized()) {
return;
}
final MapEngine engine = MapEngine.getInstance();
engine.init(new ApplicationContext(getApplicationContext()), new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(Error error) {
if (error == OnEngineInitListener.Error.NONE) {
mNotificationUtils.updateNotification(R.drawable.ic_paused, R.string.notificationTitle, R.string.notificationMapEngineReady);
if (mListener != null) {
try {
mListener.onEngineIntialized();
} catch (RemoteException ex) {
// ignored
}
}
final PositioningManager posManager = PositioningManager.getInstance();
final LocationDataSource hereLocation = LocationDataSourceHERE.getInstance();
if (hereLocation == null) {
Log.e(TAG, "initMapEngine: failed to instantiate HERE location");
return;
}
posManager.setDataSource(hereLocation);
} else {
Log.e(TAG, "initMapEngine: MapEngine.init failed: " + error.getDetails());
}
}
});
}
use of com.here.android.mpa.common.ApplicationContext in project here-android-sdk-examples by heremaps.
the class MainView method initMapEngine.
private void initMapEngine() {
// This will use external storage to save map cache data, it is also possible to set
// private app's path
String path = new File(m_activity.getExternalFilesDir(null), ".here-map-data").getAbsolutePath();
// This method will throw IllegalArgumentException if provided path is not writable
com.here.android.mpa.common.MapSettings.setDiskCacheRootPath(path);
/*
* Even though we don't display a map view in this application, in order to access any
* services that HERE Android SDK provides, the MapEngine must be initialized as the
* prerequisite.
*/
MapEngine.getInstance().init(new ApplicationContext(m_activity), new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(Error error) {
if (error != Error.NONE) {
new AlertDialog.Builder(m_activity).setMessage("Error : " + error.name() + "\n\n" + error.getDetails()).setTitle(R.string.engine_init_error).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
m_activity.finish();
}
}).create().show();
} else {
Toast.makeText(m_activity, "Map Engine initialized without error", Toast.LENGTH_SHORT).show();
}
}
});
}
use of com.here.android.mpa.common.ApplicationContext in project here-android-sdk-examples by heremaps.
the class MapListView method initMapEngine.
private void initMapEngine() {
// This will use external storage to save map cache data, it is also possible to set
// private app's path
String path = new File(m_activity.getExternalFilesDir(null), ".here-map-data").getAbsolutePath();
// This method will throw IllegalArgumentException if provided path is not writable
com.here.android.mpa.common.MapSettings.setDiskCacheRootPath(path);
MapEngine.getInstance().init(new ApplicationContext(m_activity), new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(Error error) {
if (error == Error.NONE) {
/*
* Similar to other HERE Android SDK objects, the MapLoader can only be
* instantiated after the MapEngine has been initialized successfully.
*/
getMapPackages();
} else {
Log.e(TAG, "Failed to initialize MapEngine: " + error);
new AlertDialog.Builder(m_activity).setMessage("Error : " + error.name() + "\n\n" + error.getDetails()).setTitle(R.string.engine_init_error).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
m_activity.finish();
}
}).create().show();
}
}
});
}
use of com.here.android.mpa.common.ApplicationContext in project here-android-sdk-examples by heremaps.
the class MainActivity method initSDK.
private void initSDK() {
ApplicationContext appContext = new ApplicationContext(this);
MapEngine.getInstance().init(appContext, new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(Error error) {
if (error == Error.NONE) {
startPositioningManager();
startNavigationManager();
activateSpeedLimitFragment();
} else {
Log.e("MainActivity", " init error: " + error + ", " + error.getDetails(), error.getThrowable());
new AlertDialog.Builder(MainActivity.this).setMessage("Error : " + error.name() + "\n\n" + error.getDetails()).setTitle(R.string.engine_init_error).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
MainActivity.this.finish();
}
}).create().show();
}
}
});
}
Aggregations