Android SDK Reference
Class CredoAppService.Builder
CredoAppService.Builder
CredoAppService.Builder
is responsible for creating the CredoAppService
class instance
CredoAppService.Builder(context: Context)
Parameters:
Name | Description | Type |
---|---|---|
context | An instance of Context interface, which could provide information about an application environment. | android.content.Context |
Method CredoAppService.Builder.addModule(module: IModule)
CredoAppService.Builder.addModule(module: IModule)
addModule(module: IModule) : CredoAppService.Builder
- The method adds a module to the builder configuration.
Parameters
Name | Description | Type |
---|---|---|
module | Requires one of the following modules | IModule |
Returns
CredoAppService.Builder
Method CredoAppService.Builder.addPlugin(plugin: IPlugin<*>)
CredoAppService.Builder.addPlugin(plugin: IPlugin<*>)
addPlugin(plugin: IPlugin<*>) : CredoAppService.Builder
- The method adds a plugin to the builder configuration.
Parameters
Name | Description | Type |
---|---|---|
plugin | Requires one of the following plugins | IPugin |
Returns
CredoAppService.Builder
Method CredoAppService.Builder.setIgnorePermissions(value)
CredoAppService.Builder.setIgnorePermissions(value)
setIgnorePermissions(value: Boolean) : CredoAppService.Builder
- The method sets if SDK should prevent the run of
CredoAppService.collect() or execute()
if permissions aren't granted. - The
true
value allows collecting dataset even if not all permissions are granted. - The
false
value restricts collecting dataset from running until all permissions are granted (including normal permissions). - The default value is
true
Parameters
Name | Description | Type |
---|---|---|
value | Requires Boolean value true or false | Boolean |
Returns
CredoAppService.Builder
Method CredoAppService.Builder.build()
CredoAppService.Builder.build()
build() : CredoAppService
Returns
configured CredoAppService
instance.
Class CredoAppService
CredoAppService
CredoAppService
is responsible for capturing a client's digital footprint
Method CredoAppService.collect()
CredoAppService.collect()
collect() : CredoAppResult<String>
- Collects dataset and returns it locally. This method must not be called on the UI thread.
- Does not accept any parameters
Returns
Type | Description |
---|---|
| If the |
| Returns an error if something goes wrong. Please refer to the error codes table. |
Method CredoAppService.getUngrantedPermissions()
CredoAppService.getUngrantedPermissions()
getUngrantedPermissions(): CredoAppResult<Array<String>>
Returns
Type | Description |
---|---|
| Returns an array of ungranted permissions. |
| Returns an error if something goes wrong. Please refer to the error codes table. |
Class CredoAppResult<T>.Success
CredoAppResult<T>.Success
CredoAppResult.Success
states for successful operation
Fields:
Field Name | Type | Description |
---|---|---|
value | T | Returns value of generic type. |
ClassCredoAppResult.Error
CredoAppResult.Error
CredoAppResult.Error
states for operation fail and contains error details
Fields:
Field Name | Type | Description |
---|---|---|
message | String | Returns the message value of the error. |
code | Int | Returns the code value of the error |
Class BehavioralModule
BehavioralModule
BehavioralModule()
BehavioralModule
is responsible for capturing a client's behavioral interaction with UI and OS
Static method BehavioralModule.startTracking()
BehavioralModule.startTracking()
startTracking()
- Starts behavioral interaction metadata tracking
When to invokestartTracking()
?Before version
3.0.0 <=
should be called as early as possible for instance, in desired activityonCreate()
method. If you've version>= 3.0.0
you can invokestartTracking()
in any place in your code.
Static method BehavioralModule.stopTracking()
BehavioralModule.stopTracking()
stopTracking()
- Terminates behavioral metadata tracking
Static method ` BehavioralModule.addPLugin(plugin: IBehavioralPlugin)
addPlugin(plugin: IBehavioralPlugin)
- Adds behavioral plugin to Behavioral Module
Static method BehavioralModule.setLogger(plugin: IPlugin<ILogger>)
BehavioralModule.setLogger(plugin: IPlugin<ILogger>)
setLogger(plugin: IPlugin<ILogger>)
- Sets the LoggingPlugin to BehavioralModule
Static method BehavioralModule.init(context: Context)
BehavioralModule.init(context: Context)
init(context: Context)
- Used to manually initialize the BehavioralModule in cases where auto-initialization is not available.
See Using Behavioral Module with Dynamic Feature for more details.
How to use BehavioralModule
It is necessary to call the BehavioralModule.startTracking()
method before proceeding to complete the application form. The example is below
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
BehavioralModule.setLogger(LoggingPlugin()) // optional
BehavioralModule.addPlugin(PhoneBehavioralPlugin()) // optional
BehavioralModule.startTracking()
}
}
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
BehavioralModule.setLogger(new LoggingPlugin()); // optional
BehavioralModule.addPlugin(new PhoneBehavioralPlugin()); // optional
BehavioralModule.startTracking();
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
CredolabSdkAndroidTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
Column(modifier = Modifier.testTag("root_column")) {
MainScreen("Credoapp SDK")
}
}
}
}
BehavioralModule.addPlugin(BehavioralPhonePlugin())
BehavioralModule.startTracking()
}
Add screen tracking within Jetpack Compose app
import credoapp.module.behavioral.tracker.credoAppTrackNavigation
val navController = rememberNavController().credoAppTrackNavigation()
NavHost(
navController = navController
) {
...
}
Then pass BehavioralModule
instance to CredoAppService
to collect behavioral data along with other data
class SubmitActivity : AppCompatActivity() {
// execute in background thread
fun onSubmit() {
val credoAppService = CredoAppService.Builder(applicationContext)
// add other modules
.addModule(BehavioralModule())
.build()
val result = credoAppService.collect()
when (result) {
is CredoAppResult.Success -> // send to the credolab server
is CredoAppResult.Error -> Log.d(TAG, "${result.message} ${result.code}")
}
}
}
public class SubmitActivity extends AppCompatActivity {
void onSubmit() {
CredoAppService credoAppService = new CredoAppService.Builder(applicationContext)
// add other modules
.addModule(new BehavioralModule())
.build();
CredoAppResult result = credoAppService.collect();
if (result instanceof CredoAppResult.Success) {
// send to the credolab server
} else if (result instanceof CredoAppResult.Error) {
CredoAppResult.Error errorResult = (CredoAppResult.Error) result;
Log.d(TAG, errorResult.getMessage() + " " + errorResult.getCode());
}
}
}
Highly recommendedFor successful integration, we strongly recommend assigning a value to either the ID or Tag attributes or for Jetpack Compose app testTag modifier to emphasize a specific logical control or element that holds significance within the User Flow of your app.
For example:
<Button android:id="@+id/submit_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/submit_button"/>
Button(enabled = isUpload.not(), onClick = { //.... }, modifier = Modifier.testTag("submit_btn")) { Text("Submit") }
See more examples in our Behavioral Module Identifiers Guide (Android)
How to add Behavioral Plugins to Behavioral Module
BehavioralModule.addPlugin(PhoneBehavioralPlugin())
BehavioralModule.addPlugin(new PhoneBehavioralPlugin());
Class SmsIntelligenceModule
SmsIntelligenceModule
SmsIntelligenceModule(securityParam)
SmsIntelligenceModule
is responsible for extracting SMS metadata with hashed lexical patterns protected by security param set by client. SecurityParam is required.
Parameters
Name | Description | Types |
---|---|---|
| A security parameter for hashing lexical patterns.
Throws an exception if no security parameter ( |
|
Important noteThe security parameter must remain unchanged once set and data is uploaded in production environment!
Sealed Class SecurityParam.Local
SecurityParam.Local
SecurityParam.Local(salt)
Represents a local security parameter using a custom salt for hashing
This ensures lexical pattern hashing is customized and secure.
Security Param value is never transmitted to Credolab.
Parameters
Name | Description | Type |
---|---|---|
| A string value that is used in tokens hashing functions. Required. |
|
Error Codes
Code | Reason | Description |
---|---|---|
30 | Duplicated areas error | The extracting areas are duplicated. |
43 | Permissions are not granted | If setIgnorePermissions configured method with false boolean value, SDK prevents you from proceeding without all the necessary permissions |
90 | Unknown error | An unexpected error occurred. |
Updated 12 days ago