Integration of Mars SDK consists of two major steps - adding the dependency to the application and initializing the SDK once the app is launched. Once these two steps are implemented, you can add ad units to particular place in the application.
In order to integrate Mars SDK into your application, you should add the the following dependency to the app/build.gradle file and sync Gradle:
app/build.gradle
dependencies { implementation("com.mediafy:mediafy-sdk:2.4.5") }
Add this custom maven repository URL into the project/settings.gradle file:
project/settings.gradle
repositories { maven { setUrl("https://sdk-cdn.mediafy.io/android/mediafy-sdk") } }
Import the Mars SDK core class in the main application class:
import com.mediafy.sdk.api.Mediafy
Initialize Mars SDK in the .onCreate() method by calling Mediafy.initializeSdk() method.
.onCreate()
Mediafy.initializeSdk()
class DemoApplication : Application() { override fun onCreate() { super.onCreate() // Initialize Mars SDK Mediafy.initializeSdk(applicationContext, ACCOUNT_SETTINGS) }
The Mediafy.initializeSdk() method has two parameters:
context
accountSettings
At the application initialization stage, you can also provide additional contextual information that SDK will use in the ad requests. The complete list of supported contextual signals is available in the documentation for SDK Global Parameters class.
Once SDK is initialized and contextual information is provided, it is ready to request the ads.