use of com.here.android.positioning.StatusListener in project here-android-sdk-examples by heremaps.
the class BasicPositioningActivity method initializeMapsAndPositioning.
/**
* Initializes HERE Maps and HERE Positioning. Called after permission check.
*/
private void initializeMapsAndPositioning() {
setContentView(R.layout.activity_main);
mLocationInfo = (TextView) findViewById(R.id.textViewLocationInfo);
mapFragment = getMapFragment();
mapFragment.setRetainInstance(false);
mapFragment.init(new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(OnEngineInitListener.Error error) {
if (error == OnEngineInitListener.Error.NONE) {
map = mapFragment.getMap();
map.setCenter(new GeoCoordinate(61.497961, 23.763606, 0.0), Map.Animation.NONE);
map.setZoomLevel(map.getMaxZoomLevel() - 1);
map.addTransformListener(BasicPositioningActivity.this);
mPositioningManager = PositioningManager.getInstance();
mHereLocation = LocationDataSourceHERE.getInstance(new StatusListener() {
@Override
public void onOfflineModeChanged(boolean offline) {
// called when offline mode changes
}
@Override
public void onAirplaneModeEnabled() {
// called when airplane mode is enabled
}
@Override
public void onWifiScansDisabled() {
// called when Wi-Fi scans are disabled
}
@Override
public void onBluetoothDisabled() {
// called when Bluetooth is disabled
}
@Override
public void onCellDisabled() {
// called when Cell radios are switch off
}
@Override
public void onGnssLocationDisabled() {
// called when GPS positioning is disabled
}
@Override
public void onNetworkLocationDisabled() {
// called when network positioning is disabled
}
@Override
public void onServiceError(ServiceError serviceError) {
// called on HERE service error
}
@Override
public void onPositioningError(PositioningError positioningError) {
// called when positioning fails
}
@Override
@SuppressWarnings("deprecation")
public void onWifiIndoorPositioningNotAvailable() {
// called when running on Android 9.0 (Pie) or newer
}
@Override
public void onWifiIndoorPositioningDegraded() {
// called when running on Android 9.0 (Pie) or newer
}
});
if (mHereLocation == null) {
Toast.makeText(BasicPositioningActivity.this, "LocationDataSourceHERE.getInstance(): failed, exiting", Toast.LENGTH_LONG).show();
finish();
}
mPositioningManager.setDataSource(mHereLocation);
mPositioningManager.addListener(new WeakReference<PositioningManager.OnPositionChangedListener>(BasicPositioningActivity.this));
// start position updates, accepting GPS, network or indoor positions
if (mPositioningManager.start(PositioningManager.LocationMethod.GPS_NETWORK_INDOOR)) {
mapFragment.getPositionIndicator().setVisible(true);
} else {
Toast.makeText(BasicPositioningActivity.this, "PositioningManager.start: failed, exiting", Toast.LENGTH_LONG).show();
finish();
}
} else {
new AlertDialog.Builder(BasicPositioningActivity.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) {
finish();
}
}).create().show();
}
}
});
}
Aggregations