I created a soundboard with a gridview Adapter (so no chance to set the Interstitial Ad on a sound button)
I also have a navigationbar with three tabs, so I decidet to set the Interstitial ad on the second fragment like this:
public class SecondFragment extends Fragment {
private InterstitialAd mInterstitialAd;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView=inflater.inflate(R.layout.second_layout,container,false);
final AdRequest adRequest = new AdRequest.Builder().build();
mInterstitialAd = new InterstitialAd(getActivity());
mInterstitialAd.setAdUnitId("MYID");
mInterstitialAd.loadAd(adRequest);
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
super.onAdLoaded();
if(mInterstitialAd.isLoaded()){
mInterstitialAd.show();
}
}
@Override
public void onAdClosed() {
}
});
return rootView;
}
But then the problem was that the Ad pops up with a 3 second delay, thats why I received a mail from AdMob that I have to set the Interstitial ad correctly and not like I did before.
So my question is, what would you do in this case? Where would you set the InterstitialAd?
This is my App, 3 fragments full with sound buttons: https://gyazo.com/1ecd359b38fcfe0606bb3e74b684f16e
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…