Android
Requirements
- Edit permission to your source code.
- Android development environment is setup.
Use Cases
- Track user identity and behavior on your Android mobile applications.
Guideline
Example App
Example app is in Filum Android Example repository at https://github.com/Filum-AI/filum-android-example , use Android Studio to build and run the app.
Make sure to update serverUrl
and writekey
in FILUM.initialize()
before running.
Installation
Clone filum-android-sdk
repository
git clone https://github.com/Filum-AI/filum-android-sdk
Import above module as a module
- In Android Studio, select
File
/New
/Import Module...
- Specify the path to
filum-android-sdk
Implement filum-android-sdk in build.gradle
- Open
build.gradle
of your app - Add this line
...
dependencies {
...
implementation project(':filum-android-sdk')
...
}
Usage
Initialize
final FILUM filum = FILUM.initialize( \"http://server-url.example\", \"your_project_writekey\", MainActivity.this );
Identify
identify() should be called before track() to incorporate your user_id in any upcoming track calls.
Use this method right after user has just logged in or anytime a trait of an user is updated.
try {
JSONObject user_properties = new JSONObject();
user_properties.put("Name", "Harry Potter");
user_properties.put("Email", "example@gmail.com");
}
catch (JSONException e) {
e.printStackTrace();
}
filum.identify(userId, user_properties);
Track event
Use a string to represent the event name and a JSON object to contain all custom properties.
// With custom props
try {
JSONObject props = new JSONObject();
props.put("Transaction ID", "#001");
props.put("Total Value", 1000000);
filum.track("Transaction Completed", props);
} catch (JSONException e) {
e.printStackTrace();
}
// Without custom props
filum.track("End session");
Reset
Use this method right after the user has just logged out. It will generate new anonymous ID for a new user.
filum.reset();