문제

Quick question:

In the context of an Android activity,

In an adListenner, when overriding onAdLoaded(){} and onAdFailedToLoad(int errorCode){}, should super.onAdLoaded() and super.onAdFailedToLoad(int errorCode) be called in the overriden methods?

If so, should the call be made at the beginning or end of the method?

도움이 되었습니까?

해결책 2

AdListener is an interface, there is no super class method to call.

And in any, generally in Java, Adapters (abstract Listener implementations provided for convenience) contain no implementation in the adapter. The methods are just there so that you don't need to implement those methods that you aren't using.

다른 팁

A very good question, wondering that myself - that is generally good practice, if you want to preserve the logic from the parent class. In this case it won't make a difference.

com.google.android.gms.ads.AdListener is actually an abstract class with empty methods - I believe the listener used to be an interface, which forced you to implement all methods hence the change to an abstract class.

You can take a Java decompiler like say JD-GUI and look at the code yourself (google-play-services_lib\libs\google-play-services.jar):

package com.google.android.gms.ads;

public abstract class AdListener
{
  public void onAdClosed() {}  
  public void onAdFailedToLoad(int errorCode) {}  
  public void onAdLeftApplication() {}  
  public void onAdOpened() {}  
  public void onAdLoaded() {}
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top