Banner

Banner advertising is an advertising solution that displays content at a set position, such as the top of the user's mobile phone screen. It can refresh regularly and automatically change the content of the advertisement. Users can interact with the advertisement to achieve the effect of long-term advertisement display.

The current guide shows how users can integrate banner ads into the app, as well as related usage and precautions.

Before you begin

You should finish the step of the Guide first.

Add the View in Layout

First, if you want to show the Banner, you can put the Adx3BannerAdView in the Layout of Activity or Fragment.

<io.adx3.library.view.Adx3BannerAdView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:Size="BANNER"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:unitId="UnitId" />
  • app: size - The current attribute configuration is set to the display size required by the ad. The system provides regular-size styles by default. If you do not want to use the current configuration, you can choose a custom style. Please refer to the following ad size section. For custom ad sizes, please refer to Custom Size.

  • app: united - The current ad slot id and the current attribute are used for the unique ad slot identification of your banner ad. Different types of ads use different ad slots. For specific ad slot sources, please refer to the ad configuration.

Pay attention to the current layout-adding method, the actual location of the advertisement is related to the advertisement XML, and the relevant attributes such as the specific location are bound to the page configuration

Add View directly

You can also choose to add View directly without completing XML writing.

  Adx3dBannerAdView bannerView = new Adx3BannerAdView(getContext());
  bannerview.setAdSize(AdSize.BANNER);
  bannerview.setUnitId("UnitId");

Warning: Adding view directly is the same as adding XML, you must set the unit and size of the advertisement (both complete the configuration of the above example parameters)

Custom ad slot size

After the control is created, configure the size and content of the advertisement. The size of the advertisement form can be customized, and the advertisement form and content format of different templates can be displayed according to different sizes. The required AdSize can be configured for the user-defined size, as shown below.

AdSize adSize = new AdSize(300,300);

Ad loaded

After the ad View is added, load the ad and directly call the loadAd method of the ad to complete the loading. The following example shows the complete ad-loading process.

public class MainActivity extends AppCompatActivity {
    Adx3BannerAdView bannerview;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //TODO use XML to Add AdView
        bannerview = findViewById(R.id.adView);
        
        //TODO use Create to Add AdView
        bannerview = new Adx3BannerAdView(getContext());
        bannerview.setAdSize(new AdSize(width,height));
        bannerview.setUnitId("UnitId");
        
        //TODO load the AD
        bannerview.loadAd();
    }
}

Ok, so far the ad addition and configuration have been completed, and the banner ad can be displayed automatically

Note that if the ad fails to load, if the ad slot is configured with automatic refresh, the ad SDK will automatically refresh the ad slot data after failure or success. If no ad is configured, the user can execute the loading method to manually load and refresh the ad. It is recommended to complete the automatic refresh configuration of the ad slot.

Add ad listener event

After the banner advertisement is implemented, the user can add a callback method to the method to monitor the current advertisement loading process, such as advertisement opening, advertisement closing, advertisement loading completion, and other events, which can be used for the user's subsequent business process development.

bannerView.setAdListener(new AdListener() {
            @Override
            public void show() {
            //Code to be executed when the ad has been showed int Screen
            }

            @Override
            public void loadFaild() {
            //Code to be executed when the ad load faild
            }

            @Override
            public void loadSucces() {
            //Code to be executed when the ad load success
            }

            @Override
            public void adClose() {
            //Code to be executed when the ad close by user
            }

            @Override
            public void adClick() {
            //Code to be executed when user click the ad
            }

            @Override
            public void adComplate() {
             //Code to be executed when the ad is finish   
            }

            @Override
            public void adSkip() {
            //Code to be executed when user skip the ad not wait for finish it
            }

            @Override
            public void clickUrl(String url) {
            //Code to be executed when user click the ad and tell the url to uesr
            }
        });

Advertisement monitoring method, added before the loadAd method, otherwise it may cause missing monitoring.

Operation callback method description and introduction

Name
Describetion

show()

When the ad is successfully displayed to the user page

loadFaild()

When the ad fails to load or display, the user is notified of the current ad loading failure status, and the user can check the current failure reason by viewing the error code

loadSuccess()

Prompt the user when the ad data is loaded successfully

adClose()

When the ad display is completed, the user manually or automatically closes and recycles the ad content to inform the user that the current ad process is complete

adClikck()

When the user clicks on the advertisement, the system browser is launched by default to complete the display of the advertisement link, and the user can return relevant content according to the event to make application supporting business associations, such as data links or page jumps

adComplate()

When the ad is loaded and displayed once, the complete display process can be applied to user monitoring of ad performance monitoring

adSkip()

Applicable to the notification that the user skips the advertisement and does not play the advertisement in its entirety

Ad size configuration

Provide common template size configuration

320 * 50

BANNER - Normal Size

468 * 60

LARGE_BANNER - Large Size

320 * 100

FULL_BANNER - Filling Size

custom height * custom width

User-defined ad slot height and width

Last updated