我正在制作一个简单的应用程序,在这个应用程序中我添加了一个导航抽屉和放大器抽屉项目包含网站URL链接,当我点击导航项目时,它打开了另一个带有我已经给出的网址的brawser&我在这个应用程序中放了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>
答案 0 :(得分:0)
您需要为广告实施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);
}
}