Do I need to add all ads to the.xml string?

Asked

Viewed 77 times

0

I already know that I should create a block for every actvity of my application that I want to display ads, but I don’t know how do I modify the string.xml (if any) after the first ad block has been added:

string.xml (source of the code)

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">My Application</string>
    <string name="hello_world">Hello world!</string>
    <string name="action_settings">Settings</string>
    <string name="banner_ad_unit_id">ca-app-pub-3940256099942544/6300978111</string>
</resources>

I wonder if I have to add the other ad blocks to the string.xml, but without necessarily changing the name to differentiate one from the other:

string.xml (withdrawn from here and modified by me).

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">My Application</string>
    <string name="hello_world">Hello world!</string>
    <string name="action_settings">Settings</string>
    <string name="banner_ad_unit_id">ca-app-pub-3940256099942544/6300978111</string>
    <string name="banner_ad_unit_id">ca-app-pub-1239402565465465/2363007813</string>
</resources>

Or if I have to change my name:

string.xml (withdrawn from here and modified by me).

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">My Application</string>
    <string name="hello_world">Hello world!</string>
    <string name="action_settings">Settings</string>
    <string name="banner_ad_unit_id">ca-app-pub-3940256099942544/6300978111</string>
    <string name="banner_ad_unit_id_02">ca-app-pub-1239402565465465/2363007813</string>
</resources>

Links that may be useful:

https://firebase.google.com/docs/admob/android/quick-start?hl=pt-br

https://developers.google.com/admob/android/targeting?hl=pt-br#test_ads /

https://developers.google.com/admob/android/test-ads?hl=pt-br

1 answer

0

Each ad has its own id, so.xml strings have to have items with different names to represent each id (because it’s not even possible to have any 2 items in XML with the same name).

On the other hand, you can reuse the same ad across multiple app locations. You don’t need, for example, to create 2 banners with different id’s just to display in different activities. You can use the same banner.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.