How to integrate the Android SDK - Komli Mobile

tibburfrogtownΚινητά – Ασύρματες Τεχνολογίες

14 Δεκ 2013 (πριν από 3 χρόνια και 7 μήνες)

142 εμφανίσεις



Version

2.0

KomliM
obile Android SDK

Overview

Komlim
obile

Ad banner

use a small portion of the screen to entice users to "click through" to a richer,
full
-
screen experience such as a website or app store page.

To display banners in your Android app, simply incorporate
the SDK into your Eclipse project and add
a
com.
komlibile
.sdk.
KomliMobile
View

to your UI.

Requirements

1.

Make sure you have the
latest copy of the Android SDK

and that you're compiling against at l
east
Android
v3.2

(set
target

in
default.properties

to
android
-
13
).

2.

The
KomliMobile

SDK for a
ndroid requires a run
-
time of Android
1.5

or later (set

android:minSdkVersion

to at least 3

in your

AndroidManifest.xml
). This means you can
develop with the late
st version of the Android SDK and your app will still run on an earlier Android
version (1.5 minimum).

Incorporating the SDK

Incorporating
KomliMobile

Ads into your app is a three step process:

1.

Add the SDK JAR to your Eclipse project.

2.

Declare

com
. komlimo
bile
.sdk.

KomliMobile
Activity

in

AndroidManifest.xml
.

3.

Set up required network permissions in the manifest.



Version

2.0

Adding the SDK JAR

1.

Right click on your app project in Eclipse and

choose

Properties
.


2.

Select

Java Build Path

and the

Libraries

tab. Then click

Add E
xternal JARs...

to add the
Komlimobile

Ads JAR
.






Version

2.0

com.
komlimobile
.
sdk
.
KomliMobile
Activity

The
Komlim
obile

Ads SDK requires that

com.
komlimobile
.sdk.
KomliMobile
Activity

be declared in
your app's

AndroidManifest.xml
:

<?xml version
="1.0"

encoding
="utf
-
8"
?>

<manifest
xmlns:android
=
"http://schemas.android.com/apk/res/android"











package
=
"com.company"











android:versionCode
=
"1"

android:versionName=
"1.0"
>



<application
android:icon=
"@drawable/icon"

android:label=
"@string/app_name"
















a
ndroid:debuggable=
"true"
>





<activity
android:label=
"@string/app_name"

android:name=
"
.KomlimobileAndroidSDKSample
"
>







<intent
-
filter>









<action
android:name=
"android.intent.action.MAIN"
/>









<category
android:name=
"android.intent.category.
LAUNCHER"
/>







</intent
-
filter>





</activity>





<activity
android:name
=
"com.
komlimobile
.sdk.
KomliMobile
Activity"






android:configChanges
=
"keyboard|keyboardHidden|orientation|screenLayout|uiMode|scre
enSize|smallestScreenSize"
/>

<meta
-
data
android:
name=
"client_ID"

android:value=
"MY_AD_UNIT_ID"

/>



</application>

</manifest>

Y
ou must replace
MY_AD_UNIT_ID

with your Komli
m
obile
site

id.

Permissions

Making ad requests requires the networking permissions

INTERNET

and

ACCESS_NETWORK_STATE
,

ACCESS_WIFI_
STATE, READ_PHONE_STATE, CALL_PHONE
,
so these must also be declared in the manifest
:

<?xml version
="1.0"

encoding
="utf
-
8"
?>

<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"











package=
"com.company"











android:versionCode=
"
1"

android:versionName=
"1.0"
>



<uses
-
permission
android:name=
"android.permission.INTERNET"
/>



<uses
-
permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>



<uses
-
permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>



<uses
-
permi
ssion
android:name=
"android.permission.READ_PHONE_STATE"
/>



<uses
-
permission
android:name=
"android.permission.CALL_PHONE"
/>

</manifest>





Version

2.0

Defining a com.
komlimobile
.
sdk
.
KomliMobile
View

The easiest way to incorporate an ad is to simply define your

KomliMob
ile
View

as you would any other part
of your

res/layout/main.xml
:

<?xml version
="1.0"
encoding
="utf
-
8"
?>

<LinearLayout


xmlns:android
="http://schemas.android.com/apk/res/android"


android:id=
"@+id/container"

android:background="#ffffff"
android:textColor=
"#000000"


android:layout_height=
"fill_parent"

android:orientation=
"vertical"

android:layout_width=
"fill_parent"
>


<com.
komlimobile
.sdk.
KomliMobile
View



xmlns:
komlimobile
=
"http://schemas.android.com/apk/res/ com.company"

android:layout_width=
"fill_pa
rent"

android:layout_height=
"52dip"



android:layout_gravity=
"bottom"

komlimobile
:textColor=
"#000000"


komlimobile
:mode=
"
live
"

komlimobile
:textSize="8"
komlimobile
:adRefresh=
"20"

komlimobile
:adType=
"text+picture"

komlimobile
:adSize=
"A"

komlim
obile
:rmaSupport=
"A"
/>

</LinearLayout>



textColor
, the color your text ad’s text should have. Eg: “#FFFFFF”.

mode
, the mode in which your SDK will run, set it to test while developing your app. Ensure that you set the
mode to live when distributing the ap
p to your user.

textSize
, the size of your text ads’s test.

adRefresh
, the time after which a new ad will be loaded.

The default auto refresh interval is 10 seconds.

adType
,
the type of ad (text/ picture / text+picture)

adSize
,
request for specific banner
/ creative sizes. (A / T / S / M / L / XL / XXL). A


ALL (default), T


text only,
S


small ( 120 x 20 ), M


medium ( 168 x 28 ), L


large ( 216 x 36 ), XL ( 300 x 50 ), XXL (320 x 48 / 320 x 52
).

rmaSupport
,
specify the support
for Rich Media Ad.
(
A / NA). A


a
vailable , NA


not available. Default is NA

Setting
the Test Mode

When

developing your app, set the Mode to “
test
”.

I
n
test mode you will receive all kinds of test ad.

komlimobile:mode=
"
test
"

Not
e: Ensure that you set the Mode to “
live
” when distributing the app to users. By default, Mode is
set to “live”




Version

2.0

The
attrs.
xml in the res/values folder.

Add a resource file attrs.xml to the res/values folder of your android project and copy the following code:

<?xml version=
"1.0"
encoding=
"utf
-
8"
?>


<resources>


<declare
-
styleable
name =

"com.
koml
imobile
.sdk.
KomliMobile
View
"
>


<
attr

name=
"mode"
format=
"string"
/>


<
attr

name=
"textSize"
format=
"integer"
/>


<
attr

name=
"textColor"
format=
"color"
/>


<
attr

name=
"adRefresh"
format=
"integer"
/>


<
attr

name=
"adType"
format=
"string"
/>



<attr

name=
"
adSize"
format=
"string"
/>



<attr

name=
"rmaSupport"
format=
"string"
/>


</declare
-
styleable>


</resources>



For any questions /clarifications contact

support@komlimobile.com