Android SDK
From Adfonic Wiki
Contents |
Getting Started
To get live ads in your app you just need to:
- Download the SDK and follow the integration steps below
- Sign up at http://adfonic.com/sign-up
- Add your app to your Adfonic account http://adfonic.com/sites-and-apps/add-site-or-app
- You can now get your Ad Slot ID from the Ad Integration page and replace the test id in your code - it looks like 22222222-2222-2222-2222-222222222222
Android integration in 5 steps
1. Add the adfonic_android.jar file to your project library (Eclipse screenshot)
2. Add the following to your AndroidManifest.xml (screenshot)
<!-- Insert within "application" XML tag-->
<activity android:name="com.adfonic.android.AdActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="keyboard|keyboardHidden|orientation">
</activity>
<!-- Insert after "application" closing XML tag -->
<!-- Allows applications to open network sockets to make calls to Adfonic. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Allows applications to access information about networks, wifi or gprs -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Optional, used for user location info, lat/long -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
3. Add the following to your resources attrs.xml (screenshot)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="com.adfonic.android.AdfonicAdView">
<attr name="adfonic_adslot_id" format="string"/>
<attr name="show_progress_dialog" format="boolean"/>
<attr name="progress_title" format="string"/>
<attr name="progress_text" format="string"/>
<attr name="loading_text" format="string"/>
<attr name="background_colour" format="string" />
<attr name="text_colour" format="string" />
<attr name="ad_text" format="string"/>
<attr name="test_mode" format="boolean"/>
<attr name="allow_location" format="boolean" />
<attr name="refresh_ad" format="boolean"/>
<attr name="refresh_time" format="integer"/>
<attr name="ad_width" format="integer" />
<attr name="ad_height" format="integer" />
<attr name="language" format="string" />
</declare-styleable>
</resources>
4. Add the following to your XML layout main.xml (screenshot)
<com.adfonic.android.AdfonicAdView
xmlns:app="http://schemas.android.com/apk/res/put.your.apps.package.name.here"
android:id="@+id/adview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:saveEnabled="true"
app:adfonic_adslot_id="22222222-2222-2222-2222-222222222222"
app:show_progress_dialog="false"
app:progress_title="Please wait"
app:progress_text="Loading..."
app:loading_text="Loading..."
app:background_colour="#000000"
app:text_colour="#FFFFFF"
app:ad_text="Ad: "
app:refresh_ad="true"
app:test_mode="false"
app:ad_width="300"
app:ad_height="20"
app:language="en"/>
5. Replace your package name where the namespace references "put.your.apps.package.name.here" (screenshot)
You should now see test ads in your app on your device, if you do not try the App/Site Integration Troubleshooting page. To start seeing live ads and making money you need to get your unique adfonic_adslot_id. To do that see Getting Started above.