Adding the Repository
First, add the repository to your project’sbuild.gradle file:
build.gradle
To always get the latest version:
0.11.13
Initialization
After sync, you should be able to call 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 aEnableReturnobject 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 youronActivityResultand checking theSpamControl.SpamControl_RESULTrequestCode. The result code will beandroid.app.Activity.RESULT_OKorandroid.app.Activity.RESULT_CANCELED. If it isRESULT_OK, the user granted the permissions and the service is turned on. If it isRESULT_CANCELED, the user denied at least one permission andenableSpamControlshould 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, yourapiKey(which we provide) and the user’s currentphoneNumber. This method requires that the user has internet connection to work.
enableSpamControlSilently: Turns on the service silently. It checks for the necessary permissions and returns aEnableSilentlyReturnobject. 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, yourapiKey(which we provide) and the user’s currentphoneNumber.
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.
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 ofPhoneCallobjects, 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 aDeleteCallsReturnobject.
getUserSpamNumbers: Returns a list ofUserSpamPhoneNumberobjects, 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 aBlockReturnobject.
unblockNumber: Unblocks a number. Pass the number as a trimmed number only string. Returns aUnblockReturnobject.
getAmountOfBlockedNumbers: Returns the amount of blocked numbers. Please note that this method was made for debugging purposes. It will only work in the debug artifact of this library.
getCategories: Returns a list ofCategoryobjects, each representing a category of phone numbers that can be all blocked/unblocked at once
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 currentminSdkVersion is 24.
Required Permissions
The SDK will require the following permissions to function correctly:INTERNETSince the block list is dynamic and needs to be downloaded from a server.ACCESS_NETWORK_STATETo check if there is wifi or 4g connectivity before enabling the service.READ_CONTACTSProvides access to the user’s contact list. Without this permission, it is impossible to block a call from a contact. (api 29+)READ_CALL_LOGProvides 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+).