Skip to main content
To integrate the Spam Control SDK into your Android project, follow these steps:

Adding the Repository

First, add the repository to your project’s build.gradle file:
Add the sdk as a dependency in your module’s build.gradle To always get the latest version:
To get the latest Minor and Patch versions:
Current latest version: 0.17.1

Initialization

After sync, you should be able to use the SpamControl class. It contains the following methods. Context is expected as parameter in each one. They are:
  • enableSpamControl: Turns on the service. It checks for the necessary permissions and returns a EnableReturn object that represents the synchronous result. If any permission is missing, an ui will be shown asking for it. You can listen to the result in your onActivityResult and checking the SpamControl.SpamControl_RESULT requestCode. The result code will be android.app.Activity.RESULT_OK or android.app.Activity.RESULT_CANCELED. If it is RESULT_OK, the user granted the permissions and the service is turned on. If it is RESULT_CANCELED, the user denied at least one permission and enableSpamControl should be called again. If all permissions were already granted before calling this method, the ui will not be triggered and the service will start. We expect as parameters an activity, your apiKey (which we provide) and the user’s current phoneNumber. This method requires that the user has internet connection to work. The Environment parameter defines if the service will point to Staging (STG) or Production (PROD) backend. To change Environment, the enable methods need to be called again with the new Environment (after a call to disable). It is important to notice that STG and PROD apiKeys are different. The default value for this parameter is ´PROD´.
  • enableSpamControlSilently: Turns on the service silently. It checks for the necessary permissions and returns a EnableSilentlyReturn object. If any mandatory permission is missing, the service will not be enabled. You can check by calling hasSpamControlPermissions. If all mandatory permissions were already granted before calling this method, the service will start. We expect as parameters a context, your apiKey (which we provide) and the user’s current phoneNumber. The Environment parameter defines if the service will point to Staging (STG) or Production (PROD) backend. To change Environment, the enable methods need to be called again with the new Environment (after a call to disable). It is important to notice that STG and PROD apiKeys are different. The default value for this parameter is ´PROD´
  • disableSpamControl: Turns off the service. This method doesn’t revoke any granted permissions.
  • isSpamControlOn: Returns true if the service is on and false if it is off.
  • getCurrentEnvironment: Returns the current environment, which is an enum. Possible values are STG and PROD.
  • hasSpamControlPermissions: Returns true if the app has mandatory Spam Id permission for the service to work. Returns false if it doesn’t.
  • hasSpamControlOptionalPermissions: Returns true if the app has all of the optional permissions (READ_CONTACTS && READ_CALL_LOG). Returns false if at least one permission is missing.
  • getCalls: Returns a list of PhoneCall objects, each representing a phone call that was registered by our service. Please note that we erase objects that are considered old from time to time.
  • deleteCalls: Deletes all registered calls from our registry. Returns a DeleteCallsReturn object.
  • getUserSpamNumbers: Returns a list of UserSpamPhoneNumber objects, each representing a specific number that the user manually blocked or allowed receiving calls from.
  • blockNumber: Blocks a number. Pass the number as a trimmed number only string. Returns a BlockReturn object.
  • unblockNumber: Unblocks a number. Pass the number as a trimmed number only string. Returns a UnblockReturn object.
  • getCategories: Returns a list of Category objects, each representing a category of phone numbers that can be all blocked/unblocked at once. Only categories marked as visible should be displayed to the user.
  • blockCategory: Blocks future calls from any number inside a specific spam category
  • unblockCategory: Unblocks future calls from any number inside a specific spam category
  • isNumberBlocked: Returns a Boolean that corresponds if the number is blocked or not. Please note that this method will return null if the current number is not in the user’s call history.

Minimum Android Version

Our current minSdkVersion is 24.

Required Permissions

The SDK will require the following permissions to function correctly:
  • INTERNET Since the block list is dynamic and needs to be downloaded from a server.
  • ACCESS_NETWORK_STATE To check if there is wifi or 4g connectivity before enabling the service.
  • READ_CONTACTS Provides access to the user’s contact list. Without this permission, it is impossible to block a call from a contact. (api 29+)
  • READ_CALL_LOG Provides access to the user’s call history. We use this data, like if a call was rejected or answered, as well as the call duration, to improve our spam detection.
  • POST_NOTIFICATIONS: So we can trigger notifications from time to time to let the user know how many blocks happened
  • Default dialer To allow the SDK to detect incoming calls (api 24 to 28).
  • Default spam app To allow the SDK to detect incoming calls (api 29+).