A collection of sample applications demonstrating how to use the Pathsense SDK. For more information, take a look at the Javadocs or connect with us on our website or developer portal.
You can see the additional information for each sample in their respective README files.
-
Obtain a Pathsense SDK Client ID and API Key from here. Click “GET STARTED” and enter your email address.
-
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.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 CLIENT_ID key for YOUR_PATHSENSE_SDK_CLIENT_ID in the value attribute. This element sets the key com.pathsense.android.sdk.CLIENT_ID to the value of your Pathsense SDK Client ID.
-
Substitute your API_KEY key for YOUR_PATHSENSE_SDK_API_KEY in the value attribute. This element sets the key com.pathsense.android.sdk.API_KEY to the value of your Pathsense SDK API key.
-
-
Save AndroidManifest.xml.
-
Place pathsense-android-sdk-location-bundle-release-4.1.0.0.aar under /libs
-
In build.gradle, add the following:
- to the repositories element:
repositories { flatDir { dirs 'libs' } }
- to the dependencies element:
compile(name:'pathsense-android-sdk-location-bundle-release-4.1.0.0', ext:'aar')
- for improved performance on Android Oreo and above add Google Play Services Location 15.0.1 or higher *not required
compile "com.google.android.gms:play-services-location:15.0.1"
-
Save build.gradle.
-
Re-build application.
The PathSense SDK runs as a foreground service and will post a foreground notification while in use.
By default, it will show the PathSense icon and read "Pathsense is running". You can fully customize this notification by implementing com.pathsense.android.sdk.location.PathsenseNotificationFactory
and providing your own foreground notification.
Setup includes the following:
-
Implement
com.pathsense.android.sdk.location.PathsenseNotificationFactory
and override the desired functionality. See javadoccreateForegroundNotification
: Returns the foreground notification used by PathsenseLocationProviderAPI.createForegroundNotificationId
: Returns the ID used for foreground notification.** Note: Returning the same notification and ID used by all other app foreground services allows the foreground notification to be shared and results in a single foreground notification. See android javadoc
-
Add pathsense.properties under the <module-dir>/src/main/assets folder of your app. Add the /assets folder if not already there.
-
Set the following property
notification_factory_class
to the fully qualified class name.In <module-dir>/src/main/assets/pathsense.properties:
notification_factory_class=com.myapp.MyPathsenseNotificationFactory
-
Update your proguard rules to prevent obfuscation of the notification factory class.
In <module-dir>/proguard-rules.pro:
-keep class com.myapp.MyPathsenseNotificationFactory { *; }