The DUKE.ai Load Manager goes beyond just uploading, organizing and managing documents. DUKE.ai’s Load Document Manager
Our SDK will help you get setup quick. We’ve provided a prebuilt Android Studio project so you can evaluate and use as a reference (prebuilt_project).
The following instructions will help you quickly integrate the DUKE.ai Load Manager into your app within minutes.
Add Maven dependencies in the settings.gradle file
Copy the below code and paste it into settings.gradle
maven {
url “https://jitpack.io”
credentials { username authToken }
}
Description of the above piece of code:
The above piece of code allows the Android project to fetch dependencies from the JitPack repository, provided that the appropriate credentials are provided.
Path of setting.gradle file: SDK_Testing\settings.gradle
Fig 1 – Maven dependency to add
Fig 2 – Location of the settings.gradle file in the project structure
Fig 3 – Project should look like this after adding maven dependencies
Add the dependency in build.gradle(app)
Fig 4 – Location of the build.gradle(app)
Add the following code to the build.Gradle file:
Fig 5 – Dependency to add
Fig 6 – This is how dependencies will look after updating build.gradle file
Note – You may have some dependencies already, so just add the implementation ‘com.github.DUKETEST23:DukeSDK:1.3.4’ at the end of the dependencies list.
Add Internet Permissions in the Manifest file
To access Manage Loads features, we need internet and related permissions. We can define those permissions in the AndroidManifest.xml file.
//Copy and paste these 3 permissions at the specified place
<uses-permission android:name=”android.permission.INTERNET” />
<uses-permission android:name=”android.permission.ACCESS_WIFI_STATE” />
<uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE” />
Path : ..\..\SDK_Testing\app\src\main\AndroidManifest.xml
Fig 7 – Required Android permissions to access manageLoads
Fig 8 – Location of the AndroidManifest.xml file
Fig 9 – AndroidManifest.xml – After adding required permissions
Add below code in gradle.properties
Fig 10 – Dependency for Jetifier and authToken (required to download manageLoads library)
Description of the above code
//”Jetifier” is a tool provided by Google to automatically update an Android project’s dependencies and libraries to use the latest AndroidX library versions.
android.enableJetifier=true
//Jitpack auth token to download manageLoads library from JitPack
authToken=jp_keardt0l6ik3j7mdue24op5uqh
Path : ..\..\SDK_Testing\gradle.properties
Fig 11 – Location of the gradle.properties
Fig 12 – gradle.properties – After adding dependencies
Configure Manage Load SDK
NOTE: You will need to have access unique credentials for your pool of clients. Obtain your unique client credentials by completing this form.
(Make sure you’ve completed above steps before reaching this point, otherwise the below code will throw an error in the fragment or the activity it is placed in)
Now, to access manageLoads library within an application. It needs to be invoked on a event like a button click. It can be done using the below code:
Add the below code in a fragment or an activity
public void navigateToManageLoads(View view) {
ConfigModel.client_id = “2t4UCTDnU1RWX9tqXXG8qLzFoYsAXg1CHZB3Zcf28hZJ”;
ConfigModel.api_key = “7KJbcwhabSRzxqwPmA1u6XEZFGuLaQ83Ndgeqf2EVV7h”;
ConfigModel.cust_id = “CUSTOMER_MAIL_ID”;
ConfigModel.idToken = “ID_TOKEN”;
ConfigModel.accessToken = “ACCESS_TOKEN”;
ConfigModel.refreshToken = “REFRESH_TOKEN”;
Intent in = new Intent(MainActivity.this, DashboardActivity.class);
startActivity(in);
}
Description of the above code
//Dependency to access Auth Model of the manageLoads library
import com.dukeai.manageloads.model.ConfigModel;
import com.dukeai.manageloads.ui.activities.DashboardActivity; //Dependency
//Required details to authenticate
ConfigModel.cust_id – Provide an email id
ConfigModel.api_key – Provide a api_key
ConfigModel.client_id – Provide the client_id
ConfigModel.idToken – Provide id_token
ConfigModel.accessToken – Provide access _token
ConfigModel.refreshToken – Provide refresh_token
//Code for explicit intent start manageLoads activity
Intent in = new Intent(MainActivity.this, DashboardActivity.class);
startActivity(in);
Note: If you’re copying the above code, don’t forget to import the dependencies for variables/objects such as ConfigModel, Intent, DashboardActivity and View.
Fig 11 – Button click to invoke manageLoads library on a regular activity
2. Now connect a button click event to invoke the above functionality
<Button
android:id=”@+id/button”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:onClick=”navigateToManageLoads”
android:visibility=”gone”
android:text=”Manage Loads!”
app:layout_constraintBottom_toBottomOf=”parent”
app:layout_constraintEnd_toEndOf=”parent”
app:layout_constraintStart_toStartOf=”parent”
app:layout_constraintTop_toTopOf=”parent” />
Fig 12 – Figure is showing a FrameLayout having a button click event to invoke manageLoads library. This event could be performed on any action.
Important details to keep in mind while integrating ManageLoads Library
Integrating the library following the above steps should integrate the library successfully. However, there might be issues that may occur after the SDK is integrated. To make sure there no configuration issues, please ensure:
Android gradle plugin version - 4.2.2+
Gradle version - 6.7.1+
Minimum sdk version of the parent application should be 23 in build.gradle