Android 上的 Admob - 恢复活动时未覆盖状态栏区域
我在尝试在我的应用程序中实施 Admob 时遇到了非常讨厌的错误 应用。 我认为问题出在我的代码中,但经过一番调查后我 发现它也存在于 Android-Banner-Essentials 示例中(可在 此处下载)。 我想知道是否有人遇到过这个问题或者知道如何处理 与它。
基本上,当应用程序同时禁用状态栏和标题栏时,它 应该使用全屏。 Banner Essentials 示例在页面上只显示 Admob 横幅 可用区域的顶部。 我下载了该示例,仅更改了两件事:
- 添加了我的发布商 ID 以正确编译并接收任何广告;)
- 向活动的清单添加了一个参数以禁用标题和状态 酒吧: android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
编译的二进制文件,无论在什么设备上启动(尝试过 Nexus One、G1、Desire、不同的 Android 版本),都会受到相同问题的影响:
- 当 ad显示横幅按主页,
- 返回主屏幕后按住主页即可查看最近 启动应用程序,
- 选择返回 Banner Essentials 应用程序。
我的测试表明,Admob 横幅的复制几率为 50% 返回到其位置 - 屏幕的最顶部。 为了更好地展示我的意思,我准备了三个屏幕截图:
http://img841.imageshack.us/ g/ Correctz.png/
重要提示:
- 当应用程序正常恢复时,横幅会显示在状态下方 栏,并向上滑动直到与顶部屏幕边框对齐,
- 当出现错误时横幅根本不移动,
- 我无法通过任何其他中断重现该问题(按 返回,电源按钮),
- 我认为它可能以某种方式与获得/失去焦点有关(请参阅 屏幕截图)。
我的应用程序比 Banner Essentials 复杂一些,所以我开始在代码中搜索问题,但没有成功,因此尝试尽可能简化情况,以下是结果。
有谁知道可能导致问题的原因是什么?也许必须设置一些额外的标志或属性来处理这种行为?
I'm experiencing very nasty bug trying to implement Admob in my
application.
I thought the problem is in my code, but after some investigation I
found it present also in Android-Banner-Essentials example (available for download here).
I wonder if anyone ever met this problem or maybe knows how to deal
with it.
Basically, when application has both status and title bar disabled, it
should use full screen.
Banner Essentials example displays nothing but Admob banner on the
very top of area available.
I downloaded the example, changed only two things:
- added my publisher ID to compile properly and receive any ads ;)
- added one param to activity's manifest to disable title and status
bar:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
Compiled binary, no matter what device is it launched on (tried Nexus One, G1, Desire, different Android versions), is affected with the same issue:
- When ad banner is displayed press Home,
- Once taken back to home screen press and hold Home to see recently
launched apps, - Select back Banner Essentials app.
My tests reveal that with 50% reproduction chance Admob banner doesn't
go back to its position -the very top of the screen.
To show better what I mean I prepared three screenshots:
http://img841.imageshack.us/g/correctz.png/
Important notices:
- When app is resumed normally, banner is displayed just below status
bar, and slides up until is aligned to the top screen border, - when error appears the banner doesn't move at all,
- I couldn't reproduce the issue with any other interrupt (pressing
Back, Power Button), - I think it may be somehow connected to gaining/losing focus (see
screenshots).
My app is bit more complex than Banner Essentials so I started with searching the issue in my code, with no luck, thus tried to simplify the situation as much as possible and here are the results.
Does anyone know what may be causing the problem? Maybe some additional flags or properties have to be set to handle this behaviour?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这被称为 Android 错误。没有解决方案,只有解决方法。
您必须在 onResume 后大约 1 秒重新设置窗口全屏(等待状态栏完成其精美的滑出动画...),这将导致它重新/计算整个布局,“解决”问题(使用快速跳转到正确的位置)。
这不好。但它仍然是最好的。更多信息请点击此处。
This one is referenced as an Android bug. There is no solution, just a workaround.
You have to re-set Window Fullscreen about 1 second after onResume (to wait till the status bar finishes its fancy sliding out animation...), which will cause it to re/calculate the whole layout, "solving" the problem (with a quick jump to the correct positiin).
It's not good. But it's still the best available. More info here.
就我而言,此行为是由锁定屏幕恢复触发的。不知道为什么,但在添加空重载函数后它被修复了(但我只在我的 HTC Wilfire 上测试了它)。你这可能是一个不同的错误。
In my case this behavior was triggered by resume from lock screen. No idea why but after adding empty overloaded function it was fixed (but I tested it only on my HTC Wilfire). It may be a different bug thou.