Pausing the display of ads on android

229 views
Skip to first unread message

Nick Campion

unread,
Jan 4, 2011, 1:45:25 PM1/4/11
to AdWhirl Users
For reasons beyond my control, I must multiplex an ad network with
AdWhirl. What I'd like to be able to do is pause ad requests when I
get an ad from the 'other' network. On iPhone, we use the
ignoreAutoRefreshTimer to ignore ad rotation requests that are fired
while we are 'paused.' Based on the
AdWhirlLayout:onWindowVisibilityChanged it looks like changing the
windows visibility to anything but 'VISIBLE' will cause the ad
rotations to stop happening. It looks like 'hasWindow' is set to true
in the init() method and in the onWindowVisibilityChanged. I have 2
questions: 1) is hiding the ad view the recommended mechanism for
pausing adwhirl ads and 2) should i be setting the layout's visibility
to false after init to make sure no ads are shown or is it a bug that
init() sets the hasWindow variable to true?

wes

unread,
Jan 4, 2011, 3:28:43 PM1/4/11
to adwhir...@googlegroups.com
Hiding the window containing the ad view is probably the recommended (by virtue of being the only) mechanism for pausing adwhirl ads on Android.

Regarding #2, that might be a bit of an error-by-assumption on our part.  I'll have to talk with Justin to confirm.

Cheers,
Wes

Nicholas Campion

unread,
Jan 12, 2011, 11:50:07 AM1/12/11
to adwhir...@googlegroups.com
Sorry to dig this one up, but I believe the current configuration may
not be fully delivering what you suggest bellow. I did some testing and
have some suggestions.

The current code overrides View.onWindowVisibilityChange. This covers
the case where the window is hidden intentionally by the application
developer.

However, it doesn't cover the case where the developer hides just the
view, using, for example, something like
adWhirlLayoutInstance.setVisibility(INVISIBLE). This causes the ad
frame to hide but the ad requests keep firing. My suggestion would be
to override View.onVisibilityChange in AdWhirlLayout to set hasWindow to
false if the view is hidden.

So, currently, there doesn't appear to me to be a way to pause the ads
without hiding the entire window, which won't work in my use case.

Nick

Invictus Android

unread,
Mar 2, 2011, 3:19:56 AM3/2/11
to AdWhirl Users
I would also like to have something like the "ignoreAutoRefreshTimer"
function on iOS.
We hide the ads ingame but the the refresh still takes CPU time.

The only solution seems to be to recreate the adWhirlLayout but this
is not optimal either.

Christopher Cotton

unread,
Mar 7, 2011, 1:02:43 PM3/7/11
to AdWhirl Users
Since I couldn't find any other way to pause the ads when the Activity
was paused, I created this subclass of the AdwhirlLayout. I use it
instead of the normal AdWhirlLayout. It works to pause/resume rotation
of the ads.

I just didn't want to recompile the entire AdWhirl library, which is
why I took this method. Seems to work fine on our app. If anyone has
problems and they use it, let me know.

https://gist.github.com/858891

-----
Christopher

Michael Bollmann

unread,
Apr 29, 2011, 3:36:20 PM4/29/11
to AdWhirl Users
> Seems to work fine on our app. If anyone has
> problems and they use it, let me know.
>
> https://gist.github.com/858891

I think this doesn't really work.
Suppose you pause your ad, show another activity and go back to your
activity.
In this case requests are automatically resumed.

I took your hack one step further by overriding
onWindowVisibilityChanged and
using a paused flag to determine if ads should be displayed or not.
Of course this way you have to take full control regarding the paused
flag.

http://pastebin.com/ArCe01uA

TurboChan

unread,
Oct 10, 2012, 9:23:45 PM10/10/12
to adwhir...@googlegroups.com
I really wish they had added this change you propose. Even programmatically removing the view doesn't stop it from running. I guess the Android framework continues to hold onto the view even after it's been removed. I suppose AdWhirl is more or less abandoned now anyway. Time to move on I suppose.
Reply all
Reply to author
Forward
0 new messages