implementation 'com.google.android.gms:play-services-ads:19.7.0'
public class AdManager {
boolean activityStarted;
public void onStart() {
activityStarted=true;
}
public void onStop() {
activityStarted=false;
}
public void initializeAds(Context context) {
MobileAds.initialize(context);
MobileAds.setAppMuted(true);
List<String> testDeviceIds = Arrays.asList("some id");
RequestConfiguration configuration =
new RequestConfiguration.Builder().setTestDeviceIds(testDeviceIds).build();
MobileAds.setRequestConfiguration(configuration);
}
public InterstitialAd getInterstialAdWithUnit(Context context) {
InterstitialAd mInterstitialAd = new InterstitialAd(context);
mInterstitialAd.setAdUnitId(BuildConfig.INTERSTITIAL_AD_UNIT_ID);
setAdListener(mInterstitialAd);
checkNewAdNeeded(mInterstitialAd);
return mInterstitialAd;
}
public void setAdListener(InterstitialAd mInterstitialAd) {
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
super.onAdClosed();
checkNewAdNeeded(mInterstitialAd);
}
});
}
public void showAdIfNeeded(InterstitialAd mInterstitialAd) {
if (activityStarted && mInterstitialAd.isLoaded())
mInterstitialAd.show();
else {
checkNewAdNeeded(mInterstitialAd);
}
}
public void requestNewInterstitial(InterstitialAd mInterstitialAd) {
AdRequest adRequest = new AdRequest.Builder()
.build();
mInterstitialAd.loadAd(adRequest);
}
public void checkNewAdNeeded(InterstitialAd mInterstitialAd) {
//do not load ad when acticity is stopped
if (activityStarted && !mInterstitialAd.isLoading() && !mInterstitialAd.isLoaded())
requestNewInterstitial(mInterstitialAd);
}
}
public class FullscreenActivity extends AppCompatActivity {
AdManager adManager=new AdManager();
public void onButtonClicked() {
//call another activity when Button is clicked and wait for return to display ad
activity.startActivityForResult(intent, requestCode);
runOnUiThread(new Runnable() {
@Override
public void run() {
adManager.checkNewAdNeeded(mInterstitialAd);
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
//back from other activity, try to display ads only if app has focus
if ( from activity xy) {
if (mHasFocus)
showAdWhileHasFocus();
else
showAdWhenHasFocus=true;
}
}
@Override
protected void onStart() {
super.onStart();
adManager.onStart();
}
@Override
protected void onStop() {
adManager.onStop();
super.onStop();
}
boolean showAdWhenHasFocus;
public void showAdWhileHasFocus() {
showAdWhenHasFocus=false;
adManager.showAdIfNeeded(mInterstitialAd,promotionAndAdsEvent);
}
boolean mHasFocus=false;
@Override
public void onWindowFocusChanged(boolean hasFocus) {
if (!hasFocus) {
} else {
if (showAdWhenHasFocus)
showAdWhileHasFocus();
}
super.onWindowFocusChanged(hasFocus);
}
@Override
protected void onDestroy() {
super.onDestroy();
}
}
|
||||||
Hi Alex,
Kindly note that policy-related concerns are out of scope for our level of assistance in this forum, and we do not have direct contact with the policy team responsible for checking policies for Play Store apps. You may refer to this page to learn more about ad fraud, and then reach out to either the Play Console support team (via their contact form), or to the product specialists at the AdMob Help Center, for further assistance on this.
|
||||||
Hi Alex,
I’m with Ziv’s team and I’m glad that your app is now passing the review of Google Play Store.
Thank you also for sharing your thoughts about your concern. I reviewed your previous email and you’ve mentioned that you updated your code implementing the SDK version 19.7.0 with legacy API for interstitial ad (package com.google.android.gms.ads.InterstitialAd).
However, did you ever encounter any issues during your implementation with the said API? I’m asking because the legacy API for the interstitial ad was released prior to the SDK version 19.7.0. So basically, you shouldn’t have been able to use this API in building your app in the first place as you may encounter issues during the process.
Regards,
|
||||||
|
||||||
Hi Alexander,
If you have any other concerns related to the implementation of Google Mobile Ads SDK, kindly provide us the details. We'll be happy to assist you.
Regards,
|
||||||
Hi Alexander,
We can definitively say that implementing interstitials with the deprecated Interstitial classes vs. new classes had nothing to do with the ad fraud case. It is *how* the implementation is done that matters.
In your case, one of these two things must have happened:
1) When updating your app to implement the new Interstitial API, the way in which you presented interstitials changed in a way that's now compliant with Google Play and AdMob policies. Re-review of your app shown that you are now in compliance.
2) Your account was incorrectly flagged for fraud in the first place, and upon further review, the flag was lifted.
Either way, we're happy to hear that interstitials are now working for you. But for anybody else worried that deprecated APIs automatically trigger fraud behavior, this is simply not the case.
Thanks,
Eric, Mobile Ads SDK Team