显示Admob插页式广告后应用重新启动

时间:2014-03-29 06:20:22

标签: android admob google-play-services

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

ISSUE: 在某些手机中,我可以看到每次关闭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 :(得分:0)

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

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

答案 1 :(得分:0)

您可以修改onCreate方法:

private void Form1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
    if (e.KeyCode == Keys.Enter && e.Control)
    {
        // Stuff
        e.IsInputKey = false;
    }
}

就像这样,广告仅在重新开始时显示。

相关问题