Table of Contents | ||
---|---|---|
|
Prerequisites
Do Get Started all the way until finishing step 3
...
Then add this application class to the manifest you already had from the Get Started.
The code for adding the application is the following
...
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> |
We will come back to this Application class to add our testing single tag data, but let's first add the tagged wrappers and events
Tagged wrappers
Tagged Wrappers are the container inside which the ads will show, they are normal wrappers with the android:tag
attribute set. You need to add as many as you can, remember that placing a tagged wrapper does not mean we need to use it.
...
Transitions events are detected by the single tag automatically after initialization. They happen when an activity or fragment is started from other activity or fragment.
Button Presses when a button is pressed, this works They are detected by adding the
android:tag
attribute to the button.
Ex of transition:
Code Block |
---|
class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main_auto) findViewById<Button>(R.id.goToNewsPost).setOnClickListener { val intent = Intent(this, NewsPostDetailActivity::class.java).apply { putExtra("newsPostData", newPostData) } startActivity(intent) } } } |
Info |
---|
In this example an interstitial would be triggered when we see the |
...
Ex of button press:
with this button code
Code Block |
---|
# activity_main.xml ... <Button android:id="@+id/play_video_trailer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:tag="play_video_trailer_tag" /> ... |
...
Note |
---|
This step is for testing purposes and you are only going to see test ads when using this approach, but this is very helpful to us if you provide this peace of code to tell us where you want to place the ads. Later when in production, this code have been removed and you have hopefully added flexible tagged wrappers and tagged all the button as possible so we can change your ad slots from the server without the need of updating the app. |
Go into production
for For going into production you will need to use you ids:
Remove the methods
R89SDK.setDebug()
andaddTestingSingleTagData()
Change the Google app id in the manifest for the production one
Change the
appId
andpublisherId
in the initialization method for the production onesit’s also recommended to remove
R89SDK.setLogLevel(LogLevels.DEBUG)
but not needed
...