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

0

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

string.xml ( source 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'll have to add the other ad units to the string.xml code, but not necessarily rename it to differentiate one from the other:

string.xml (removed 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 happen to have to change the name:

string.xml (removed 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:

link

link /

link

    
asked by anonymous 23.08.2017 / 02:58

1 answer

0

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

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

    
23.08.2017 / 06:10