Turns out I had too many problems with the HTML route. Instead
I have gone with the SDK,i.e. I put LeadBolt’s pubiapp.jar in my
libs directory and made a LeadBolt interstitial activity.
It just displays a circular ProgressBar on a black background
until an ad arrives. If the user presses the “x” to get rid of
the ad, then the activity does a finish, allowing it to go back
to the calling activity. If an ad fails to load, the activity
does a finish().
I’m sharing the code here, partly so that anyone can use it, and
partly because someone may spot some possible improvements… or bugs!
====================================================================
Leadbolt.xml
<?xml version=“1.0” encoding=“utf-8”?>
<LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:gravity=“center”
android:orientation=“vertical” >
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Advertisement"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
LeadBoltInterstitialActivity.java
package com.yourcompany.yourapp;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import com.pad.android.iappad.AdController;
import com.pad.android.listener.AdListener;
public class LeadBoltInterstitialActivity extends Activity implements AdListener
{
String TAG = “LB”;
String LeadBoltSectionID = “PUT YOUR NINE DIGIT NUMBER HERE”;
private AdController myLeadBoltController;
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.leadbolt);
myLeadBoltController = new AdController(this, LeadBoltSectionID ,this);
myLeadBoltController.loadAd();
}
public void onAdLoaded()
{
Log.i(TAG,"onAdLoaded()");
// add app specific code for this event here...
// called when an ad is successfully displayed on device
}
public void onAdClicked()
{
Log.i(TAG,"onAdClicked()");
// add app specific code for this event here...
// called when an ad is clicked by user
}
public void onAdClosed()
{
Log.i(TAG,"onAdClosed()");
// add app specific code for this event here...
// called when the ad window is closed by user
proceed_to_destination();
}
public void onAdCompleted()
{
Log.i(TAG,"onAdCompleted()");
// add app specific code for this event here...
// supported for Advanced Overlay & Form Capture template types.
// called when ad window is closed with successful conversion
}
public void onAdFailed()
{
// add app specific code for this event here...
// called when the ad request to the ad server has failed
// e.g No Internet connection
// if destroyAd needs to be called in this function please use
// following code
Log.i(TAG,"onAdFailed()");
this.runOnUiThread(new Runnable()
{
public void run()
{
if(myLeadBoltController != null)
{
myLeadBoltController.destroyAd();
}
}
});
proceed_to_destination();
}
public void onAdAlreadyCompleted()
{
// add app specific code for this event here...
// triggered when loadAd() is called & current device has recorded
// a successful conversion
Log.i(TAG,"onAdAlreadyCompleted()");
}
public void onAdHidden()
{
// deprecated – replaced by onAdPaused()
Log.i(TAG,"onAdHidden()");
}
public void onAdPaused()
{
// add app specific code for this event here...
// triggered when loadAd() is called & pauseAd() has previously
// been called by App Developer
Log.i(TAG,"onAdPaused()");
}
@Override
public void onAdResumed() {
// add app specific code for this event here...
// triggered when resumeAd() is called by App Developer
Log.i(TAG,"onAdResumed()");
}
@Override
public void onAdProgress() {
// add app specific code for this event here...
// call every x seconds while ad loading is in progress
// x must be set by calling myController.setOnProgressInterval(x);
// this function is off by default
Log.i(TAG,"onAdProgress()");
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
myLeadBoltController.destroyAd();
super.onDestroy();
}
void proceed_to_destination()
{
// if the calling activity has already called its finish(),
// then this finish() will exit the app altogether.
// if the calling activity did not call its finish(),
// then this finish() will return to the calling app.
finish();
}
}
I’ll be damned if I can work out how to keep the indentations using this forum’s editor!