java - 如何在应用退出后停止显示插页式广告?
<p><p>我的应用会在应用中显示插页式广告,有时会在应用因网速慢而关闭后显示。在应用关闭后显示插页式广告违反了 admob 规则。如何在应用关闭后阻止插页式广告展示广告??</p>
<p></p><div class="snippet"data-lang="js"data-hide="false"data-console="true"data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>public class des extends AppCompatActivity {
ImageButton imageView15;
InterstitialAd mInterstitialAd;
private InterstitialAd interstitial;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_des);
AdView mAdView = (AdView) findViewById(R.id.AdView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
// Prepare the Interstitial Ad
interstitial = new InterstitialAd(des.this);
// Insert the Ad Unit ID
interstitial.setAdUnitId(getString(R.string.intertitial_id));
interstitial.loadAd(adRequest);
// Prepare an Interstitial Ad Listener
interstitial.setAdListener(new AdListener() {
public void onAdLoaded() {
// Call displayInterstitial() function
displayInterstitial();
}
});
imageView15 = (ImageButton) findViewById(R.id.imageView15);
imageView15.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intentLoadNewActivity = new Intent(des.this,vid.class);
startActivity(intentLoadNewActivity);
}
});
}
public void displayInterstitial() {
// If Ads are loaded, show Interstitial else show nothing.
if (interstitial.isLoaded()) {
interstitial.show();
}
}
}</code></pre>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>问题是您在 OnAdLoaded 中显示不建议的添加。这会导致不良行为并在用户执行其他工作时拦截。所以您应该在 Activity 开始时加载您的广告,然后您应该显示它在通过检查是否已加载用户不受影响的时候。
这样,在用户使用完您的应用后,您的广告将不会显示,您的问题将得到解决。</p></p>
<p style="font-size: 20px;">关于java - 如何在应用退出后停止显示插页式广告?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/42670489/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/42670489/
</a>
</p>
页:
[1]