-
Notifications
You must be signed in to change notification settings - Fork 18
Getting Started
To start using Navigation library in your project you should do the following steps.
Register on http://locations.navigine.com, create a location and get your personal security key in the profile (it has the form 16 hexadecimal digits: XXXX-XXXX-XXXX-XXXX
).
Use jitpack to integrate SDK to your project jitpack page. OR Download "libnavigine.aar" and add it to the Android project.
Initialize Navigation library in your code before any other library functions are called:
// Initialize Navigine library
Navigine.initialize(Context);
// Set user hash and server before getting the instance of [[NavigineSdk|class-NavigineSdk]]
NavigineSdk mNavigineSdk = NavigineSdk.getInstance();
mNavigineSdk.setUserHash(mUserHash); // your user hash from the server
mNavigineSdk.setServer(mLocationServer); // your server url (by default `https://ips.navigine.com`)
If mNavigineSdk
is null than library is not initialized and cannot be used. This generally happens in one of the following cases:
- Android SDK version is less than 21;
- Android device doesn't support Bluetooth 4.0;
- CPU architecture is not supported yet.
Get instance of LocationManager, set LocationListener and download a location archive from the server using the following (or similar) code:
LocationManager mLocationManager = mNavigineSdk.getLocationManager();
mLocationManager.addLocationListener(new LocationListener() {
@Override
public void onLocationLoaded(Location location) {
// do smth with location
}
@Override
public void onDownloadProgress(int progress, int total) {
// do smth with location download progress
}
@Override
public void onLocationFailed(Error error) {
// do smth if error occurs during downloading location
}
});
mLocationManager.setLocation(/* your location id */);
If location archive was successfully loaded you can start navigation (see NavigationManager for details). You can set the LocationView and it will display your position, or you can use NavigationManager and get updates about your position through PositionListener.
NavigationManager mNavigationManager = mNavigineSdk.getNavigationManager();
mNavigationManager.addPositionListener(new PositionListener() {
@Override
public void onPositionUpdated(Position position) {
// do smth with position
}
@Override
public void onPositionError(Error error) {
// do smth if error occurs during downloading location
}
});
Add following code in layout xml file
<com.navigine.view.LocationView
android:id="@+id/location_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
Use LocationView in your code
public class NavigationFragment extends Fragment {
LocationView mLocationView;
LocationManager mLocationManager
IconMapObject mPosition = null;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mLocationView = view.findViewById(R.id.location_view);
mPosition = locationView.getLocationViewController().addIconMapObject();
mPosition.setSize(30, 30);
mPosition.setBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.blue_dot));
mLocationManager = mNavigineSdk.getLocationManager();
mLocationManager.addLocationListener(new LocationListener() {
@Override
public void onLocationLoaded(Location location) {
locationView.getLocationViewController().setSublocationId(location.getSublocations().get(0).getId());
}
@Override
public void onDownloadProgress(int progress, int total) {
// do smth with location download progress
}
@Override
public void onLocationFailed(Error error) {
// do smth if error occurs during downloading location
}
});
}
}
Tutorials
Classes
- NavigineSdk
- LocationListManager
- LocationManager
- NavigationManager
- RouteManager
- ZoneManager
- NotificationManager
- MeasurementManager
- LocationEditManager
- ResourceManager
- Location
- Sublocation
- Category
- Venue
- Zone
- Beacon
- Eddystone
- Wifi
- LocationView
- LocationViewController
- CircleMapObject
- PolylineMapObject
- IconMapObject
- TouchInput
- ScaleResponder
- PanResponder
- LongPressResponder
- DoubleTapResponder
- TapResponder
- LocationListListener
- LocationListener
- PositionListener
- RouteListener
- ZoneListener
- NotificationListener
- LocationEditListener
- MeasurementListener
- ResourceListener
- ResourceUploadListener
- Notification
- Position
- SignalMeasurement
- SensorMeasurement
- Image
- RoutePath
- RouteEvent
- LocationPoint
- LocationInfo
- BitmapRegionDecoder