-
Obtain a Google Maps Android API Key from here.
-
Obtain a PathSense SDK Client ID and API Key by contacting PathSense.
The legacy “GET STARTED” portal is no longer active. SDK credentials are issued privately.
-
In AndroidManifest.xml, add the following elements as children of the <application> element, by inserting them just before the closing </application> tag:
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="YOUR_GOOGLE_MAPS_API_KEY" /> <meta-data android:name="com.pathsense.android.sdk.CLIENT_ID" android:value="YOUR_PATHSENSE_SDK_CLIENT_ID" /> <meta-data android:name="com.pathsense.android.sdk.API_KEY" android:value="YOUR_PATHSENSE_SDK_API_KEY" />
-
Substitute your API key for
YOUR_GOOGLE_MAPS_API_KEYin the value attribute.
This setscom.google.android.maps.v2.API_KEYto your Google Maps Android API key. -
Substitute your Client ID for
YOUR_PATHSENSE_SDK_CLIENT_ID.
This setscom.pathsense.android.sdk.CLIENT_IDto your PathSense SDK Client ID. -
Substitute your API Key for
YOUR_PATHSENSE_SDK_API_KEY.
This setscom.pathsense.android.sdk.API_KEYto your PathSense SDK API Key.
-
-
Save AndroidManifest.xml.
-
Place pathsense-android-5.0.0.0.aar under /libs
-
In build.gradle, add the following:
- to the repositories element:
repositories { flatDir { dirs 'libs' } }- to the dependencies element:
implementation(name:'pathsense-android-5.0.0.0', ext:'aar')
- (Optional) For improved performance on Android O and above, add Google Play Services Location — not required:
implementation "com.google.android.gms:play-services-location:21.3.0" -
Save build.gradle.
-
Re-build the application.
-
Create a Broadcast Receiver that will receive in-vehicle location updates.
- For convenience, you can extend
com.pathsense.android.sdk.location.PathsenseInVehicleLocationUpdateReceiver.
public class PathsenseInVehicleLocationDemoInVehicleLocationUpdateReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { PathsenseInVehicleLocation inVehicleLocation = PathsenseInVehicleLocation.fromIntent(intent); if (inVehicleLocation != null) { // handle location update } } }
- For convenience, you can extend
-
In AndroidManifest.xml, add the following element as a child of the <application> element, by inserting it just before the closing </application> tag:
<receiver android:name=".PathsenseInVehicleLocationDemoInVehicleLocationUpdateReceiver" />
-
In MapActivity (or any other Context object), instantiate the API:
PathsenseLocationProviderApi api = PathsenseLocationProviderApi.getInstance(context);
-
Request in-vehicle location updates by calling
requestInVehicleLocationUpdateswith the receiver created in step #1:api.requestInVehicleLocationUpdates(PathsenseInVehicleLocationDemoInVehicleLocationUpdateReceiver.class);
- Until
removeInVehicleLocationUpdates()is called, the receiver will continue to receive in-vehicle location updates.
- Until
SDK Version: 5.0.0.0 Android Target: 16 (API 36) Play Services: 21.3.0 or newer
© PathSense Inc. — Updated for SDK 5.0.0.0 / Android 16 (API 36)