This widget was written by Funky Android Ltd. and is made available under the following BSD style license;
Copyright (c) 2009, Funky Android (www.funkyandroid.com) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3) Neither the name of the project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
In order to use the widget you will need to do the following
You've now done all you need to do on the OpenX side. You can alter the configuration as you wish, but we'd recommend starting simple so that any potential issues are easily found.
There are only three things you'll need to do to serve ads in your app. These are;
<com.funkyandroid.openx.widget.OpenXWidget android:id="@+id/advert" android:layout_width="fill_parent" android:layout_height="60px" android:layout_weight="0" android:background="#888">We've set the height to 60px because we're using a 234x60 pixel banner and setting this lets the OS know how much space the ad needs. We've set a background because we think it looked pretty :).
OpenXWidget widget = (OpenXWidget)findViewById(R.id.advert); widget.setServer("d1.openx.org"); widget.setZoneId(90810);You'll need to replace the server specified (in our case d1.openx.org) with the server from step 3 of the OpenX instructions above, and you'll need to replace the zoneId (in our case 90810) with the zone ID from step 4 of the OpenX instructions above.
You're then ready to roll.
The demo application will serve an ad for AndAppStore, so it's a good place to start. If you change the values in the demo application for your server and zone and you use an IAB Half Banner for your zone you can simply update Main.java with your values and you should see your ads served (if not you should check your OpenX configuration, your zones ID, and your OpenX server name). If you're not using an IAB Half Banner zone then you'll also need to update the main.xml layout file to alter the size of the widget.