【问题标题】:After click AdMob ads, I cannot return to my Android app by back button点击 AdMob 广告后,我无法通过返回按钮返回我的 Android 应用
【发布时间】:2013-12-18 16:33:13
【问题描述】:

我使用以下代码在我的应用程序中添加 AdMob。

<?xml version="1.0" encoding="utf-8"?>
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:orientation="vertical" >
<com.google.ads.AdView 
    android:id="@+id/adview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    ads:adSize="SMART_BANNER" 
    ads:adUnitId="ca-app-pub-*************************"
    ads:loadAdOnCreate="true"
    ads:testDevices="********************"
    />
 <TabHost
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        >

        <TabWidget
            android:id="@android:id/tabs"
            android:textSize="12sp"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >
        </FrameLayout>
    </LinearLayout>
 </TabHost>
</LinearLayout>

广告显示在我的手机上。但是,当我触摸“返回”按钮时,它不会返回到我的应用程序。相反,它会返回到我之前查看过的手机网页。 欢迎提出任何建议。

【问题讨论】:

    标签: android admob banner


    【解决方案1】:

    请在你的清单中试试这个

    <activity android:name="com.google.ads.AdActivity"
         android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
    android:noHistory="true">
    

    尤其是“noHistory”。它对我有用。

    【讨论】:

      【解决方案2】:

      对我来说,这是预期的行为,因为我偶尔会遇到这种情况。一旦用户点击广告,后退按钮就会与随后打开的任何应用程序相关联。通常是 Google Play 或您手机的浏览器。

      在 Google Play 中,点击返回通常会将您直接带回您的应用。但是,在您的浏览器中,按返回将带您返回上一次查看的页面(如在浏览器中按返回),或者如果没有任何页面,则返回您的应用。

      一旦用户点击了广告,你就无法控制返回按钮了,真的。

      【讨论】:

      • 奇怪的是我不能再使用我的应用程序了。如果我点击我的应用程序,它将进入广告网页。点击广告后如何使用我的应用?
      【解决方案3】:

      当点击 admob 广告时,整个互联网浏览器应用程序都会启动,而不仅仅是一个显示网页的活动。正如 badgerati 所说,这就是您的应用位于堆栈中 Internet 浏览下方的原因。 为了更加突出这个问题,当您启动图库应用程序以查看图像(从您的应用程序)时,只有 Vies Image 活动启动,而不是整个 galary 应用程序因此当您单击返回时您返回到您的应用程序.. 但不幸的是浏览器不一样

      【讨论】:

      • 在我的测试设备中,点击广告会进入 Play 商店。然后,我单击“返回”按钮,它仍然卡在 Play 商店中。它不是浏览器。
      • 我看到我的应用程序屏幕闪烁了一秒钟,然后它又回到了 Play 商店。
      • 您是否尝试在其他设备上进行测试?
      • 我在我的手机三星 Galaxy S 3 上进行了测试。然后,我在几分钟前在模拟器上进行了测试。在三星 Galaxy S 3 上,单击“返回”按钮将闪现我的应用程序屏幕,然后返回 Play 商店。在模拟器上,我的应用程序屏幕将在模拟器的下底部显示为非常小的屏幕,并以广告屏幕为背景。如果我点击那个小屏幕,我的应用程序会正确返回。
      • 似乎有点奇怪.. 我建议您删除该活动和与该活动相关的 xml 文件,并重新开始您的应用程序的该部分.. 这有时会有所帮助
      【解决方案4】:

      听起来您可能错误地配置了 AndroidManifest 中的 Application 或 Activity 属性之一。类似 launchMode、noHistory、allowTaskReparenting 等。

      发布您的 AndroidManifest。

      【讨论】:

      • 我没有任何选择,除了名字和标签。
      【解决方案5】:

      当我让'Don't save activities' 签入Settings|Developers Options. 时,这发生在我身上。如果未选中(通常应该如此)一切正常。

      【讨论】:

        猜你喜欢
        • 2012-04-25
        • 1970-01-01
        • 2017-12-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-01-18
        • 1970-01-01
        相关资源
        最近更新 更多