Prerequisites
Do Get Started all the way until finishing step 3
Initialize the SDK
Note |
---|
We require the SDK to be initialized only once as early as possible so for this purpose using Android’s application is recommended but if your app only has one activity, if using the activity make sure it is never destroyed unless killing the app or placing it in the background, matching then the lifecycle of Application, you can initialize it in onCreate method of that Activity. |
Let’s see the recommended method.
Create an Application
class and add it to the manifest code to start the app with the Application
class.
Code Block | ||||
---|---|---|---|---|
| ||||
class Application: Application()
{
override fun onCreate()
{
super.onCreate()
R89SDK.setDebug() //This is for testing purposes, remove it on prod
R89SDK.setLogLevel(LogLevels.DEBUG) //This is for testing purposes, remove it on prod
R89SDK.initialize(
appContext = this,
publisherId = "TestRefinery89ID", /* This is for testing purposes, change it on prod */
appId = "TestDemoApp", /* This is for testing purposes, change it on prod */
singleLine = false,
initializationEvents = null
)
}
} |
Then add this application class to the manifest you already had from the Get Started.
The code for adding the application is the following
Note |
---|
Remember that the |
Code Block | ||
---|---|---|
| ||
<manifest>
<application
android:name=".Application">
</application>
</manifest> |
With this addition you full manifest should look like so:
Note |
---|
This is a simplified example, you should have many more lines in the manifest, copy the important bits only. |
Code Block |
---|
<manifest>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
<application
android:name=".Application"
>
<!-- This is the Sample App ID-->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
</application>
</manifest> |