Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4125472
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:52:26+00:00 2026-05-20T23:52:26+00:00

Hi I am working on an android app and using AdWhirl to display my

  • 0

Hi I am working on an android app and using AdWhirl to display my ads. I want to be able to handle the situation when AdWhirl returns no ads. When it fails, I want to show a decorative bar.

Can anyone provide me an example?

Thanks in advance,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:52:26+00:00Added an answer on May 20, 2026 at 11:52 pm

    OK I’ve figured this out now. There are two possible ways, where one is very easy and the other requires a little bit more work.

    The easy way

    The adwhirl layout stays invisible as long as it has nothing to show. So you can simply create a FrameLayout containing your fallback view in the background and the adwhirl view in the front similar to this:

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="53dp"
            android:layout_gravity="center_horizontal"
            >
        <!-- fallback view -->
        <TextView
            android:id="@+id/ad_fallback"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:text="nothing to say..."
            >
    </FrameLayout>
    

    In your code you can then add the view to the layout (where parentView is the inflated layout shown above):

    final DisplayMetrics dm = activity.getResources().getDisplayMetrics();
    final AdWhirlLayout adView = new AdWhirlLayout(activity, ADWHIRL_ID);
    adView.setMaxWidth((int) (dm.density * 320));
    adView.setMaxHeight((int) (dm.density * 53));
    adView.setGravity(Gravity.CENTER);
    parentView.addView(adView);
    

    That’s it.

    The more sophisticated way

    In GoodNews though I wanted a more sophisticated way: An “ad loading …” message should be shown while AdWhirl is busy fetching ads and if it has nothing to fill in an internal ad banner (provided as resource in the app, so that it even works if internet is not available) should be displayed. The loading message is easy, as it can be implemented like shown above, but the dynamic internal banner is a little bit more tricky.

    The solution are the mighty custom events provided by AdWhirl which are — unfortunately — badly documented. The first step to take is to create a custom event in the AdWhirl web interface:

    1. bring up the “Ad Network Settings”
    2. click the “Ad Custom Event” button at the top
    3. enter an arbitrary name (e.g. “fallback”) and function name (the latter one will directly map to a method name in your Java class)
    4. enable the event at give it an allocation of 0%
    5. now bring up the “Backfill Priority” screen and move your fallback event to the end of the list

    The configuration above ensures, that your custom event will only be fired when AdWhirl isn’t able to show any real ads.

    Now you need to handle the event in your code. Therefore you need a class that implements the AdWhirlLayout.AdWhirlInterface and defines a public method without parameters and a name equal to the function name specified by the custom event. This method can then inject your specific view into the AdWhirl layout:

    class AdWhirlEventHandler implements AdWhirlLayout.AdWhirlInterface {
        private final AdWhirlLayout adView;
    
        public AdWhirlEventHandler(AdWhirlLayout adView) {
            this.adView = adView;
        }
    
        @Override
        public void adWhirlGeneric() {
            // nothing to be done: Generic notifications should also be 
            // configurable in the AdWhirl web interface, but I could't find them
        }    
    
        /**
         * Will be called by AdWhirl when our custom event with the function name 
         * "fallback" is fired. Called via reflection.
         */
        public void fallback() {
            try {
                final View fallbackView = 
                    ... // inflate the view to be shown here
                adView.pushSubView(fallbackView);
    
                /*
                 * reset backfill chain and schedule next ad update
                 */
                adView.adWhirlManager.resetRollover();
                adView.rotateThreadedDelayed();
            } catch (MyExpectedException ex) {
                /*
                 * forward to next option from the backfill list
                 */
                adView.rolloverThreaded();             
            }
        }
    }
    

    Now you need to register your event handler with the AdWhirlLayout like this:

    adView.setAdWhirlInterface(new AdWhirlEventHandler(adView));
    

    That’s it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an Android app that needs to be able to display information
I have been working on an Android app using Phonegap and now would like
I'm using C2DM to send notification for my android App and it is working
I am working on an app for android using phonegap and unity. I wrote
I am working with Amazon In-app-purchases for Android on flash using native extentions. So,
Building an app using android.support.v4.app , targeting API level 8. Everything's working as planned
In my Android app, I log in using the Facebook SDK and display posts
I am developing an Android app using Phonegap and jQueryMobile, working in Eclipse. I
I am working on an android app in which I am using some Native
I am working on an android app which links to facebook (using the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.