I have some ads that take a very long time to load. I was wondering it it is possible to have them load while the use was in the splash screen. I have looked at this answer:

And the answer suggests to use a splash screen to load the ads. How can I figure out when the ads are loaded, to continue to my next activity? What will happen if the user is on airplane mode, will it get stuck in the splash screen? I have seen the admob add listener, but that needs the adview, but my adview is in the next activity? How should I tackle this problem?

Also, when I try to do this:

 AdView.setAdListener(new AdListener() {
});


I get:

Non-static method cannot be referenced from a static context. The thing is, I am trying to see when the add which is in the next activity is done loading.

• Your static issue is due to something trying to treat an instance method as if it were static. perhaps part of your implementation is attempting to use a non-static method as if it were static OR one of your implemented functions should be static... – Troyseph Dec 4 '15 at 10:02
• Also I'd advise against making the player wait while the ad is loading. Load it in the background, then when appropriate show it. Waiting for Ads to load feels like punishment to a player and can put them off playing. – Troyseph Dec 4 '15 at 10:03
• @Troyseph And how would I do that? Thanks – NullPointerException Dec 7 '15 at 3:18
• try this bfy.tw/39nB – Troyseph Dec 7 '15 at 10:35

Your stack error comes from the fact that 'AdView' is a type, not an instance. For example, let's say you have the following class:

package simulator;

import java.awt.Color;

public class Dog {

public Color coatColor;
public static boolean mans_best_friend;

}


because all dogs are man's best friend, the statement

Dog.mans_best_friend = true;


is a valid statement, because the static modifier lets you use the type to set a variable. Likewise, you cannot have the statement

Dog.coatColor = Color.BROWN;


because 'Dog' doesn't refer to a specific dog object.

-

This means that you have to get a

new AdView();


Object somehow. If you read up on the documentation, there are usually 2 common ways to get the object.

1) a constructor: this is a simple allocation of new memory on the computer in order to hold all the variables it contains, usually fast, but inefficient to do multiple times. it gives you a fresh object

2) a GetInstance() method: It's more of a workaround that a method, it allows for one object to be created and allows for maximum efficiency of code, with absolute minimum customization.

Best of luck in finding a way to get your AdView Object!