首页 文章

显示Admob interestial后,应用程序重新启动

提问于
浏览
0

我有一个使用旧ADMOB SDK的应用程序 . 我已经开始使用Google Play服务库来展示ADMOB interestial广告 . 我每次活动开始时都有广告 .

问题:在某些手机中,我可以看到每次关闭AD后活动都会重新启动 . 因此我只能看到广告 . 我还发现活动到达onDestroy() . 有什么方法可以用它吗?

请帮我解决这个问题

Android Manifest

<supports-screens            
 android:xlargeScreens="true" 
 android:largeScreens="true"
 android:normalScreens="true"
 android:smallScreens="true"
 android:anyDensity="true" />   

<!-- Used to request banner and interstitial ads. -->
<uses-permission android:name="android.permission.INTERNET"/>
<!-- Used to avoid sending an ad request if there is no connectivity. -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/memorygamefreelogo"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen">

    <meta-data android:name="com.google.android.gms.games.APP_ID"
               android:value="@string/app_id" />
    <meta-data android:name="com.google.android.gms.version"
               android:value="@integer/google_play_services_version"/> 

     <!-- Activity required to show ad overlays. -->
    <activity  android:name="com.google.android.gms.ads.AdActivity"
               android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

    <activity
        android:name="com.example.Splash"
        android:label="Memory Game" 
        android:noHistory="true"
        android:screenOrientation="landscape"
               android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize">

        <intent-filter>
            <action   android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

    </activity>

    <activity
        android:name="com.splash.MemoryHome"
        android:label="memorygame" 
        android:screenOrientation="landscape"
               android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize">
        <intent-filter>
            <action android:name="android.intent.action.memorygame.free.MEMORYHOME" /> 
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

    <activity
        android:name="com.splash.MemoryGame"
        android:label="memorygame" 
        android:screenOrientation="landscape"
               android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize">
        <intent-filter>
            <action android:name="android.intent.action.memorygame.free.MEMORYGAME" /> 
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

</application>

2 回答

  • 0

    当您展示插页式广告时,会启动新的(InterstitialAd)活动 . 这意味着您的当前活动将不再可见,并且将调用Activity#onStop .

    Android框架 may 也决定从内存中删除你的Activity . 如果它这样做,它 may 调用Activity#onDestroy . 这解释了您在某些手机之间看到的差异 . 我不知道有任何影响这种行为的方法 .

  • 0

    您可以修改onCreate方法:

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        if (savedInstanceState == null) {
            showAd();
        }
    }
    

    像这样,广告只在新的开始时显示 .

相关问题