Integrate Massive SDK into your Fire OS application with this guide.
Android SDK Level | 21 (Lollipop) or later |
Kotlin version | 1.9.0 or later |
Java version | 17 or later |
android.permission.INTERNET |
android.permission.ACCESS_NETWORK_STATE |
android.permission.FOREGROUND_SERVICE |
android.permission.FOREGROUND_SERVICE_DATA_SYNC |
android.permission.WAKE_LOCK |
Sample Application (Android / Fire OS) | Download |
API_TOKEN
at the end of MainActivity.kt
.sampleapp
.https://downloads.joinmassive.com/sdk/android/release
to the dependency repositories
used by the project.
It can be defined in different places depending on your project.
Common places are:
global settings.gradle.kts
toml
file for dependency configuration, add the following to the toml
:
gradle
file as:
MassiveClient
in your Activity
or Application
class. Ensure you do this at the start of the application lifecycle.
start()
method and created options:
com.massive
to com.joinmassive
.
MassiveClient
has shifted from using a singleton instance to utilizing static methods. This change simplifies interaction with the SDK, making it more straightforward to initialize and manage the client throughout the application lifecycle.
start
method. This allows for more dynamic configuration, enabling modification of the service options at the time of starting the client rather than during initialization. This separation ensures a quicker initialization process and more flexible configuration management.
stop
: The behavior of the stop method has been enhanced. In the new version, calling stop
not only stops the usage but also shuts down the service entirely. This ensures that all operations are cleanly terminated and the service is properly shut down, providing a more robust mechanism for managing the SDK’s lifecycle.
repositories
.
android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE
android.permission.FOREGROUND_SERVICE
android.permission.FOREGROUND_SERVICE_DATA_SYNC
android.permission.WAKE_LOCK
MassiveClient.init
, which requires your API token. This initialization step is crucial and should be performed only once during the application’s lifecycle. Subsequent calls to init
will have no effect. Attempting to re-initialize the SDK with a different API token will result in a MassiveReinitException
, ensuring that the SDK maintains a single consistent state throughout the app’s runtime.
Since the SDK consists of client and service components, initialization can trigger synchronization of their states. To handle this scenario and achieve accurate state tracking, you can pass an additional callback to the init
method. This callback will be called in the main thread after synchronization is complete.
start()
method), it is mandatory to obtain user consent for the terms of resource exchange. This aligns with user privacy and control principles. Ensure that your application includes a clear and understandable consent mechanism.
MassiveClient
with the init()
method does not automatically launch the service or start the usage.
It prepares the SDK for use but does not begin its operation.
To ensure that the Massive is running, the start()
method must be called after initialization and on each application relaunch. The start()
method is designed to be idempotent, meaning it is safe to call multiple times. If the service is already started, subsequent calls to start will have no effect, preventing redundant operations.
The stop()
method is used to stop and kill the service, effectively halting all operations and ensuring that the service is properly terminated. After calling stop()
, you can restart the client by calling the start()
method again, and it is possible to provide different options for the restart. This flexibility allows you to change the configuration or operational mode of the SDK as needed.
com.joinmassive.sdk.R.drawable.massive_sdk_icon
, but you can also provide your own.
usage
method in the MassiveClient
class fetches and returns the current traffic usage in bytes. Please check the sample application for an example of how to use the method to retrieve and display the traffic usage statistics.