I have been trying to implement Leadbolt ads in my app but I am unable to set the Adlistener on the Controller. The methods I can add are nothing like the methods described in the pdf. I can display ads in my app, but cannot use listeners.

This is my code:

 final Activity act = this;
                  myController = new AdController(act, MY_LB_SECTION_ID, new AdListener() {

                    @Override
                    public void onDismissScreen(Ad arg0) {
                        // TODO Auto-generated method stub

                    }

                    @Override
                    public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
                        // TODO Auto-generated method stub

                    }

                    @Override
                    public void onLeaveApplication(Ad arg0) {
                        // TODO Auto-generated method stub

                    }

                    @Override
                    public void onPresentScreen(Ad arg0) {
                        // TODO Auto-generated method stub

                    }

                    @Override
                    public void onReceiveAd(Ad arg0) {
                        // TODO Auto-generated method stub

                    }

                  });

                  myController.loadAd();

The error I get is: The constructor AdController(Activity, String, new AdListener(){}) is undefined

This is the code from the pdf file, but these methods seem to be unknown for eclipse:

final Activity act = this;
AdController myController = new AdController(act, 
"MY_LB_SECTION_ID", new AdListener() {
public void onAdLoaded() {
}
public void onAdClicked() {
}
public void onAdClosed() {
act.finish();
}
public void onAdCompleted() {
act.finish();
}
public void onAdFailed() {
act.finish();
}
public void onAdProgress() {
}
public void onAdAlreadyCompleted() {
act.finish();
}
public void onAdHidden() {} // function is deprecated
public void onAdPaused() {
act.finish();
}
public void onAdResumed() {
}
});
myController.loadAd();

Any ideas, what am I doing wrong? I haven't added anything to the Manifest.

有帮助吗?

解决方案 2

To Leadbolt:

It turned out that com.pad.android.listener.AdListener; or com.Leadbolt.AdListener; collided with import com.google.ads.AdListener; which is the AdMob AdListener. That's why I couldn't add the import statement.

You should extend your documentation, so if your listener collides with any other ad networks, how to use it, because it's not obvious. MobFox is also using com.adsdk.sdk.AdListener.

To use your AdListener while using other ad networks' AdListeners, this is how my first line looks like:

public class MainActivity extends Activity implements AdListener, com.google.ads.AdListener {

The first one is MobFox, the second one is AdMob. I didn't implement leadbolt's AdListener, because I am using it in the code:

AdController myController = new AdController(act, MY_LB_SECTION_ID_BANNER_ALL, new com.pad.android.listener.AdListener() {

This way it's working.

其他提示

From the PDF you referenced:

Once this code is included, access your publisher portal and add an “App Ad (SDK)” section and use the get code icon to retrieve the value for “MY_LB_SECTION_ID”.

MY_LB_SECTION_ID is the integer ID, not a string.

I had the same problem, as I also use AdMob simultaneously but I found an easier way to fix this.

Instead of using:

AdController ad = new AdController(act, "MY_LB_SECTION_ID", new AdListener() {
    ...
}

I used:

AdController ad = new AdController(act, "MY_LB_SECTION_ID", new com.<leadbolt_package_name>.AdListener() {
    ...
}

Keeping into consideration that I used this import:

import com.<leadbolt_package_name>.AdController; // in my case, it was something like 'fgadcbgxysr'

This will read directly the LeadBolt library method and not the colliding one. Hope it helps other users, though my response came late.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top