Android
attention
The minimal required Android SDK version is 14.
Install the library
Add the ClientSecurityModule’s repository to your project’s build.gradle file under allprojects:
allprojects {
repositories {
...
maven {
url 'https://riskident.jfrog.io/riskident/android-release'
credentials {
username '<YOURUSERNAME>'
password '<YOURPASSWORD>'
}
}
...
}
}
Add the ClientSecurityModule to your module’s build.gradle file:
dependencies {
...
compile 'com.riskident.device:clientsecuritymodule:<LIBRARY_VERSION>'
...
}
Integration
Create a main application class
... if you don’t have one. In case you have one, go to the next step. As an example we create a file named MainApplication.java with the following content:
MainApplication.java
public class MainApplication extends Application
{
@Override public void onCreate()
{
super.onCreate();
}
}
Following the example you must add a new android:name=.MainApplication
tag to your AndroidManifest.xml inside the application xml tag. Your AndroidManifest.xml will look like this:
AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
If you already have an application
... make sure you have the internet permission declared in your AndroidManifest.xml:
AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
Add the ClientSecurityModule to your application
Initialize ClientSecurityModule in your main application class:
import com.riskident.device.ClientSecurityModule; // add this line
public class MainApplication extends Application
{
@Override public void onCreate()
{
super.onCreate();
ClientSecurityModule.initialize("<SNIPPET_ID>"); // add this line
}
}
Collect and send data to Risk Ident
To use the ClientSecurityModule inside of your activities use the following code:
ClientSecurityModule.getInstance().execute(this, "<TOKEN>", "<LOCATION>");
or
ClientSecurityModule.getInstance().execute(this, "<TOKEN>");
If you want to transmit data from a fragment, you must always provide an instance of your current activity.
For example:
ClientSecurityModule.getInstance().execute(getActivity(), "<TOKEN>", "<LOCATION>");
or
ClientSecurityModule.getInstance().execute(getActivity(), "<TOKEN>");
<LOCATION>
indicates where the user is currently navigating in the app.
attention
If you get the error com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
you must enable MultiDex for your application. Use the official Android guide for more details: Enable multidex for apps with over 64K methods