Dashboard module of TelematicsApp-Android
This module is created by DATA MOTION PTE. LTD. and allows you to integrate with our UserStatistic API and Dashboard view in a few steps.
Before you start using this module, make sure you registered a company account in DataHub. If you are new, please refer to the documentation and register your company account in DataHub. Sing Up
- Download from this repository dashboard_module folder
- Move this folder to the project folder next to the
app
folder - In your
settings.gradle (Project settings)
addinclude ':dashboard_module'
- Import module:
dependencies {
...
implementation project(':dashboard_module')
}
Getting the object and setting the context for the module.
val dashboardModule = DashboardModule.getInstance()
dashboardModule.initialize(context)
You will need an api key to display a preview of the last trip on the map.
dashboardModule.setHereMapApiKey(hereApiKey)
Step 1: After creating your HERE account, open your project in https://developer.here.com/projects
In the REST table click "Generate App".
Step 2: Click "Create API key"
Copy API KEY and paste it to setHereMapApiKey
method.
val credentials = Credentials(deviceToken, accessToken)
dashboardModule.setCredentials(credentials)
deviceToken
- is the main individual SDK user identifier. This identifier is used as a key across all our services.
accessToken
- or JSON Web Token (JWT) is the main UserService API key, that allows you to get user individual statistics and user scoring by UserStatistics API calls.
A value that determines when the dashboard will be unlocked to display statistics and scorings.
dashboardModule.setDashboardMileageLimitKm(10)
Getting a fragment to display in your container.
val fragment = dashboardModule.getDashboardFragment()
Here's an example of using the DashboardModule.
private fun showDashboard(deviceToken: String, accessToken: String, hereMapKey: String) {
//initialize
val dashboardModule = DashboardModule.getInstance()
dashboardModule.initialize(this)
//set here map api key
dashboardModule.setHereMapApiKey(hereMapKey)
//set credentials
val credentials = Credentials(deviceToken, accessToken)
dashboardModule.setCredentials(credentials)
//set distance limit
dashboardModule.setDashboardMileageLimitKm(10)
//get dashboard fragment
val dashboardFragment = dashboardModule.getDashboardFragment()
// show fragment
val container = R.id.container
val manager: FragmentManager = supportFragmentManager
val transaction: FragmentTransaction = manager.beginTransaction()
transaction.replace(container, dashboardFragment)
transaction.commit()
}
You can also check full exaple in this repository: DashboardDemoApp
Happy coding!
Official API services web-page