how to carry same ad in all activities?

1.1k Views Asked by At

I have 5 activities in a row one after another. I have integrated admob ads in that. But my problem is after new activity opens the ad on activity before it get destroyed and my current activity starts reloading ad. Major problem is before my ad finish loading, user moves to next screen.

so my question is Is there any whay to carry your loaded ad in all your activities so that no need of reloading ad again and again for each activity?

I heard about ViewStub. Will it help me ?

2

There are 2 best solutions below

3
On BEST ANSWER

You can create one XML file in which you can put your adView Component and include that XML into your all 5 activities XML

this is the very simple way of integrating adView into android project

Second thing it is good if new ad is reloading in new activity cause it will help you to get more revenue from admob if ad will not get refresh then number of impression will not get increase so its good that when user goes on new activity ad get refresh

about your concern i.e (before my ad finish loading, user moves to next screen.) if user realy interesting in ad he/she will surely wait for loading

now choice is yours what you want you want more revenue by more number of impression or you want to show same ads to user in all 5 activities

for that you need to use same footer bar in xml and you need to just change the middle section of screen then you can achieve it easily as per your requirement

0
On

Hey Friend What you want is not possible in android you say masterPage concept of ASP.net but that is not possible with Activity. if you want to do that then you can do it with Fragment. take Fragments instead of Activity then you can achive your goal.