Android - Banner Ad
Compatible with Vpon SDK v4.9 and below
Compatible with Vpon SDK v4.9 and below
Vpon Banner can be embedded to part of your app layout. It consists of a multimedia object which can attract user. The ads will expand to show much richer content after clicking.
Please make sure you’ve imported Vpon SDK to your Xcode project. If not, please refer to our Integration Guide to finish your setting.
Android apps are composed of View objects, such as text areas, buttons and other components. VpadnBanner is simply another View subclass displaying HTML5 ads that triggered by user’s touch.
Please follow the steps below to implement Vpon Banner Ad to your application:
com.vpadn.ads.*
VpadnBanner
instanceWe strongly recommend that you can finish all the steps in the Activity of the application.
Please follow the instruction below to add Banner Ad in your MainActivity.
import com.vpadn.ads.*;
public class MainActivity extends Activity implements VpadnAdListener {
private RelativeLayout adBannerLayout;
// Declare VpadnBanner instance
private VpadnBanner vponBanner = null;
// Please fill in with your License Key
private String bannerId = "License Key" ;
...
}
public class MainActivity extends Activity implements VpadnAdListener {
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Get your layout view for Vpon banner
adBannerLayout = (RelativeLayout) findViewById(R.id.adLayout);
// In SDK 4.8.0 and below, create VpadnBanner instance
vponBanner = new VpadnBanner(this, bannerId, VpadnAdSize.SMART_BANNER, "TW");
// In SDK 4.8.1 and above, create VpadnBanner instance
vponBanner = new VpadnBanner(this, bannerId, VpadnAdSize.SMART_BANNER);
vponBanner.setAdListener(this);
VpadnAdRequest adRequest = new VpadnAdRequest();
// Set "true" to enable banner ad auto refresh
adRequest.setEnableAutoRefresh(true);
// Load vpon banner
vponBanner.loadAd(adRequest);
// Add vpon banner to your layout view
adBannerLayout.addView(vponBanner);
}
@Override
protected void onDestroy() {
super.onDestroy();
if (vponBanner != null) {
//remember to call destroy method
vponBanner.destroy();
vponBanner = null;
}
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:vpadn="http://schemas.android.com/apk/lib/com.vpadn.ads"
android:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/adLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<!-- Implement Vpon Banner Ad As Below -->
<com.vpadn.ads.VpadnBanner
android:id="@+id/vpadnBannerXML"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
vpadn:adSize="SMART_BANNER"
vpadn:autoFresh="true"
vpadn:bannerId= "License Key"
vpadn:loadAdOnCreate="true"
vpadn:platform="TW" />
</RelativeLayout>
</LinearLayout>
Not:e Please replace the parameter of vpon:bannerId with your License Key
Please add the code snippet to your application and fill in with your test device’s UUID as below to request for test ads.
public class MainActivity extends Activity implements VpadnAdListener {
...
VpadnAdRequest adRequest = new VpadnAdRequest();
HashSet<String> testDeviceImeiSet = new HashSet<String>();
// Add Android device advertising id
testDeviceImeiSet.add("your device advertising id");
adRequest.setTestDevices(testDeviceImeiSet);
vponBanner.loadAd(adRequest);
...
}
Here are some tips for you to get your advertising id:
public class MainActivity extends Activity implements VpadnAdListener {
@Override
public void onVpadnReceiveAd(VpadnAd ad){
Log.d("Banner", "VpadnReceiveAd");
}
@Override
public void onVpadnFailedToReceiveAd(VpadnAd ad, VpadnAdRequest.VpadnErrorCode errCode){
Log.d("Banner", "fail to receive ad (" + errCode + ")");
}
@Override
public void onVpadnPresentScreen(VpadnAd ad){
Log.d("Banner", "VpadnPresentScreen");
}
@Override
public void onVpadnDismissScreen(VpadnAd ad){
Log.d("Banner", "vpadnDismissScreen");
}
@Override
public void onVpadnLeaveApplication(VpadnAd ad){
Log.d("Banner", "VpadnLeaveApplication");
}
}
Vpon Banner supports three tablet-only banner sizes in addition to the 320x50 shown on phones:
Size (WxH) | Description | VponAdSize Constant |
---|---|---|
320x50 | Standard Banner | VpadnAdSize.BANNER |
300x250 | IAB Medium Recangle | VpadnAdSize.IAB_MRECT |
468x60 | IAB Full-Size Banner | VpadnAdSize.IAB_BANNER |
728x90 | IAB Leaderboard | VpadnAdSize.IAB_LEADERBOARD |
device width x auto height | Smart Banner | VpadnAdSize.SMART_BANNER |
We recommend that you can use the Smart Banner
constant. (VpadnAdSize.IAB_WIDE_SKYSCRAPER is not available currently)
Please refer to our Sample Code for a complete integration sample.
Please refer to the link below to learn more about other ad types: