[英]Admob interstitial ads issue?
我正在制作一個簡單的應用程序,在此應用程序中,我添加一個導航抽屜,並且當我單擊導航項目時,抽屜項目包含網站網址鏈接,這是打開的另一個瀏覽器,具有我提供的網址,並且我在此應用程序中放置了Google admob廣告因此,當我單擊此項目時,打開了帶有admob插頁式廣告的頁面,但是我的問題是,當顯示廣告時,我單擊了“后退”按鈕。 ),但現在當我關閉admob插頁式廣告時,再次打開我的應用程序。 如何解決該問題,請任何人幫助我。
觀看視頻以更好地了解: https : //drive.google.com/open?id=0B8YTgurIRbm5SS01YW1WRHptYlU
我的AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="26" />
<supports-screens
android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<application
android:allowBackup="true"
android:icon="@mipmap/logo_icon"
android:label="@string/app_name"
android:roundIcon="@mipmap/logo_circle"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".SpleshScreen.SpleshScreen"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
android:configChanges="orientation|screenSize">
</activity>
<service android:name=".Messaging.MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent"
android:noHistory="true"/>
</application>
您需要為廣告實現adListner(),在初始化非頁內廣告代碼后將其放入代碼中
InterstitialAd mInterstitialAd = new InterstitialAd(getActivity());
mInterstitialAd.setAdUnitId(mContext.getString(R.string.admob_ad_unit_id_interstitial));
mInterstitialAd.loadAd(new AdRequest.Builder().
build());
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
super.onAdClosed();
// perform your task after the ad is closed
Intent intent = new Intent(CurrentAct.this, GoToAct.class);
startActivity(intent);
// load the ad again if you need to show it again
mInterstitialAd.loadAd(new AdRequest.Builder().
build());
}
@Override
public void onAdLoaded() {
super.onAdLoaded();
}
});
// open your ad
btnclick(){
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
// if your ad is not ready to be shown, perform your task here
Intent intent = new Intent(CurrentAct.this, GoToAct.class);
startActivity(intent);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.