|
Here is sample code that can be
used to natively serve ads to Android devices using Ban Man Pro.
This code fully supports the Ban Man Pro Zone Refresh Interval
for automatically pulling a new ad every X seconds. This
code has only been tested in Ban Man Pro 11.
First you must modify the Manifest.xml file to
include the line shown below which MUST appear the
<application
android:icon="@drawable/icon"
android:label="@string/app_name"
android:debuggable="true">
tag.
New line for Manifest.xml file:
<uses-permission
android:name="android.permission.INTERNET"
/>
Next, in the main.xml file found under
res\layout you must define a
WebView
within the
<LinearLayout...</LinearLayout>
tag.

< WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
Now, here is sample code to populate the
WebView with an ad.
/** Called
when the activity is first created. */
@Override
public
void
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView mWebView;
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://<Your URL to Ban Man Pro>/a.aspx?Task=Get&ZoneID=16&SiteID=2");
}
In this code you must replace
<Your URL to Ban Man Pro>
with the full URL where you installed Ban Man Pro. You
must also replace ZoneID=16 and SiteID=2 with your actual ZoneID
and SiteID.
Full documentation on the WebView Class is available on the
Android web site by clicking here.
|