【问题标题】:Admob interstitial ads issue?Admob 插页式广告问题?
【发布时间】:2018-01-03 11:10:45
【问题描述】:

我正在制作一个简单的应用程序,在这个应用程序中,我添加了一个导航抽屉和抽屉项目,当我单击导航项目时,它会打开另一个带有我提供的 url 的 brawser 并且我放置了 google admob 广告在这个应用程序中,所以当我点击这个项目页面打开时,admob 插页式广告很好,但我的问题是当显示广告时,我点击后退按钮广告关闭,我的应用程序再次打开,但我想显示该页面(我的 url显示在浏览器中)但现在当我关闭 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>

【问题讨论】:

  • 你能澄清你的问题吗,这没有意义,你的视频也没有帮助。

标签: android admob ads interstitial drawer


【解决方案1】:

您需要为广告实现 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);
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多