mOcean_BlackBerry_Developer_Documentation_2_1.docx

looneyvillestaticΛογισμικό & κατασκευή λογ/κού

15 Αυγ 2012 (πριν από 5 χρόνια και 1 μήνα)

364 εμφανίσεις



Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
1









BlackBerry

mOcean

Java

SDK

Developer Guide

V 2.1





















Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
2



Table of Contents

Overview

................................
................................
................................
................................
...................

3

System requirements:

................................
................................
................................
...........................

3

SDK
contents:

................................
................................
................................
................................
........

3

Library version:

................................
................................
................................
................................
......

3

What’s new:

................................
................................
................................
................................
..........

3

Feature List:

................................
................................
................................
................................
...........

3

Creating sample project with Eclipse IDE:

................................
................................
................................
.

4

Creating sample project with

Netbeans IDE:

................................
................................
..........................

10

Creating sample project with BlackBerry IDE:
................................
................................
.........................

14

AdServer Constructor:

................................
................................
................................
.............................

17

Global functions:

................................
................................
................................
................................
.

17

AdServerIn
terstitial Constructor:

................................
................................
................................
............

20

Usage examples:

................................
................................
................................
................................
.....

20

Adserver control:

................................
................................
................................
................................
.

20

AdserverInterstitial control:

................................
................................
................................
................

20

Stoping and refreshing Adserver content:

................................
................................
..........................

21

Update Ad content right now:

................................
................................
................................
............

21

Stopping and starting Ad update:

................................
................................
................................
.......

21






Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
3


Overview

This document provides a description of the following:



System requirements



Installation Instructions



SDK contents



SDK API reference



Sample of usage

System requirements:



Microsoft Windows XP or
later.



IDE, supports BlackBerry environment:

o

Eclipse (
http://us.blackberry.com/developers/javaappdev/javaplugin.jsp
)

o

Netbeans
(
http://netbeans.org/downloads/index.html
) with Blackberry plugin
(
http://plugins.netbeans.org/PluginPo
rtal/faces/PluginDetailPage.jsp?pluginid=11194

)

o

BlackBerry JDE (
http://us.blackberry.com/developers/javaappdev/javadevenv.jsp

)

SDK

contents:

Release


SDK libraries for approp
riate BlackBerry OS

Sample
s

-

S
ample usage

app
lication


Library version
:

Warning : this version work only on BB OS 5.0 and higher, 4.X OSes not supported

For Blackberry OS’es

5
.0

and higher

use Adserv
er.jar located in
\
Releases
\

folder.

What’s new
:

-

Better javascript support due to BrorserField2 component

-

Millennial ad support through external campaign

-

Caching data

-

DataRequest class

Feature List
:

-

Supported ads type

-

Interstitial Ad

-

Open links in external web browser

-

Phone user
-
agent auto detection or
defined value

-

Predefined ip address or ip auto detection

-

Predefined country code country code auto detection

-

Phone carrier auto detection

-

Predefined user location of auto detection

-

Landscape or portrait phone orientation

-

Callback notification





Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
4


Creating sa
mple project with Eclipse IDE:


1)

Open eclipse with
your

workspace and
go to

New => BlackBerry Project

2)

Type project name (ex. AdserverTest):

3)

I
mport
mOcean

SDK
into
lib

folder

4)

Add
mOcean

SDK
jar

into project build path

5)

Open sample project properties and open

Java Build Path.

6)

Open “
Orde
r

and Export
” tab and select
Adserver.jar

7)

Create package “mypackage” and add into MyApp.java and MyScreen.java into them

8)

Run


Example content of MyApp.java:


package

mypackage
;


import

net.rim.device.api.ui.UiApplication;


/**


* This class extends the UiApplication class, providing a


*
g
raphical

user interface.


*/

public

class

MyApp

extends

UiApplication

{


/**


* Entry point for application


*
@param

args Command line arguments (not used)


*/



public

static

void

main(String[] args)


{


MyApp

theApp =
new

MyApp
();


theApp.enterEventDispatcher();


}





/**


* Creates a new
MyApp

object


*/


public

MyApp
()


{


pushScreen(
new

MyScreen
());


}

}


Example content of MyScreen.java:


package adsevertest;


import net.rim.device.api.ui.container.MainScreen;


import com.adserver.core.Adserver;



Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
5



/**


* A class extending the MainScreen class, which provides default standard


* behavior for BlackBe
rry GUI applications.


*/

public final class AdserverScreen extends MainScreen {



public AdserverScreen() {



super();

setTitle
(
"Simple Ad Sample"
);






Adserver field =
new

Adserver(8061, 20249);



field.setSize(320,50);



field.setUpdateTime(3);



add(
field);


}

}





Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
6








Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
7








Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
8













Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
9










Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
10


Creating sample project with
Netbeans

IDE:


Preparing IDE:

1)

Run installed

Netbeans IDE

2)

Go to Tools => Plugins => Downloaded and push “Add Plugin” button

3)

Select downloaded netbeans blackberry
plugin
, press OK,

and then push “Install” button

4)

Restart netbeans

5)

Go to Tools => Java Platforms. Push “Add Platform” button and select “Java ME MIDP Platform
Emulator”

6)

System will search installed jdk’s, then select BlackBerry
JDK in result list


Creating sample project:

1)

F
ile => New Project

2)

Select Java ME => Mobile Application

3)

Type project name (ex. AdserverTest); Uncheck “Create Hello Midlet”

4)

Select “Emulator platform” (ex. Blackberry JDE 5.0.0)

5)

Open create project folder in any file manager and create folder
lib
.

6)

Copy
mOcean

SDK jar into
lib

folder, copy build.xml and bb
-
build.xml
(provided with that doc)

in
to
project folder (replace original

build.xml)

7)

Open in netbeans AdserverTest
properties

8)

Go to Build => Libraries & Resources

9)

Push “Add Jar/Zip” and select
mOcean

SDK
jar from our
lib

folder. Check “package” option.

10)

Create package “mypackage” and place into them two files MyApp.java, MyScreen.java provided in
“Eclipse IDE” example.

11)

To alter project title, version, icon and vendor manually edit build.xml

12)

Go to
Run

=> Run

Main Project



Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
11






Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
12







Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
13







Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
14


Creating sample project with
BlackBerry

IDE:


1)

Open BlackBerry JDE, create sample workspace

2)

Create new project “mOcean
_sdk” that will contain our
mOcean

SDK library

3)

Copy Adserver.jar inside project directory

4)

Go to
“mOcean_sdk
=>
Add File to Project

5)

Select
mOcean

SDK library file (File Type set “All files”)

6)

Go to
mOcean
_sdk => Properties

7)

Click the
Application

tab. From the
Project Type

drop
-
down list, select
Library
.

8)

Right
-
click
mOcean
_sdk project
and click
Build Project
.

9)

Create
new project “
mOcean
_sample” that will contain our
mOcean

SDK sample

10)

Create new source files MyApp.java and MyScreen.java (
mOcean
_sample => C
reate new File in
Project); Defi
n
ing package name in

Project name field (ex. mypackage
\
MyApp.java)

11)

Place code from
“eclipse IDE” instruction

12)

Right
-
click

mOcean
_sample project
and click
Project
Dependencies

13)

Check
mOcean
_sdk field

14)

Go to Build => Build and Run

mOcean
_sample project








Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
15










Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
16







Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
17


AdServer
Constructor
:

public Adserver(
int
site
,
int

zone)

Parameters:

site
-

The id of the publisher site (default: DEFAULT_SITE).



zone
-

The id of the zone of publisher site (default: DEFAULT_ZONE).


Global functions:

All settings can be set by means of methods get and set (for example: getCity() and setCity(String cit
y)).

java.lang.String

getAdserverUrl
()


Optional.


java.lang.String

getAdvertiserId()


Optional.


java.lang.String

getArea()


Optional.


java.lang.String

getBackgroundColor()


Optional.


java.lang.String

getCarrier
()


Optional.


java.lang.String

getCity()


Optional.


java.lang.String

getCountry()


Optional.


java.util.Hashtable

getCustomParameters()


Optional.


java.lang.
String


getDefaultImage()


Optional.


java.lang.String

getGroupCode()


Optional.


boolean

getInternalBrowser()


Get the flag which operates advertising opening.


java.lang.String

getKeywords()


Optional.


java.lang.String

getLatitude()


Optional.


java.l
ang.String

getLongitude()


Optional.


java.lang.Integer

getMaxSizeX()


Optional.


java.lang.Integer

getMaxSizeY()


Optional.


java.lang.String

getMetro()


Optional.


java.lang.Integer

getMinSizeX()


Optional.


java.lang.Integer

getMinSizeY()


Optional.



Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
18


java.lang.Integer

getPremium()


Optional.


java.lang.String

getRegion()


Optional.


java.lang.String

getSite()


Get the id of the publisher site.


java.lang.Strin
g

getState()




java.lang.Boolean

getTest()


Optional.


java.lang.String

getTextColor()


Optional.


java.lang.Integer

getUpdateTime()


Optional.


java.lang.String

getZip()


Optional.


int



getZone()


Get the id of the zone of publisher site.

void

setAdserverURL(java.lang.String adserverURL)


Optional.


void

setAdvertiserId(java.lang.String advertiserId)


Optional.


void

setArea(java.lang.String area)


Optional.


void

setBackgroundColor(java.lang.String backgroundColor)


Optional.


void

setCarrier(java.lang.String carrier)


Optional.


void

setCity(java.lang.String city)


Optional.

void

setCountry(java.lang.String country)


Op
tional.


void

setCustomParameters(java.util.Hashtable<java.lang.String,java.lang.String> customParameters)


Optional.


void

setDefaultImage(java.lang.Integer defaultImage)


Optional.


void

setGroupCode(java.lang.String groupCode)



Optional.


void

setInternalBrowser(boolean internalBrowser)


Set the flag which operates advertising opening.


void

setKeywords(java.lang.String keywords)


Optional.


void

setLatitude(java.lang.String latitude)


Optional.


void

setLongitude(java.lang.String longitude)


Optional.


void

setMaxSizeX(java.lang.Integer maxSizeX)


Optional.



Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
19



void

setMaxSizeY(java.lang.Integer maxSizeY)


Optional.


void

setMetro(java.lang.String metro)


Optional.


void

setMinSizeX(java.lang.Integer minSizeX)


Optional.


void

setMinSizeY(java.lang.Integer minSizeY)


Optional.


void

setOnAdClickListener(AdServerViewCore.OnAdClickListener adClickListener)


Set interface for adve
rtising opening.


void

setOnAdDownload(AdServerViewCore.OnAdDownload adDownload)


Set interface for advertising downloading.


void

setPremium(java.lang.Integer premium)


Optional.


void

setRegion(java.lang.String region)


Optional.


void

setSite(
int

site)


Required.


void

setTest(java.lang.Boolean enabled)


Optional.


void

setTextColor(java.lang.String textColor)


Optional.


void

setUpdateTime(java.lang.Integer updateTime)


Optional.


void

setZip(java.lang.String zip)


Optional.


void

setZone(
int

zone)


Required.

void

update()


Immediately update banner contents.


void
update()
-

Immediately update banner contents


Callbacks:

Warning :

callback names changed since version 2.0

boolean

didAdClicked (String
url
)


This event fired after user clicks the banner Return True if you are handled the event and do not
want the control to show internal popup window.



void
onStartLoading
()


This e
vent is fired before banner download begins.

void
onLoaded
()


This event is fired after banner content fully downloaded.

void
onError
(Stri
ng error)

This event is fired after fail to download content.





Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
20



AdServer
Interstitial

Constructor
:

public Adserver
Interstitial
(
int

site
,
int

zone)

Parameters:

site
-

The id of the publisher site (default: DEFAULT_SITE).



zone
-

The id of the zone of publisher site (default: DEFAULT_ZONE).


Usage examples:

Adserver control
:

1.

Create new Adserver object:

Adserver

field = new Adserver
(8061,

16112
);

2.

Set optional parameters:

Hashtable customParameters = new Hashtable();

customParameters.put("key1", "value1");

customParameters.put("key2", "value2");

field.setCustomParameters(customParameters);

field.
setMaxSizeX(new In
teger(300));

and so on

3.

Set field size in pixels:

field.setSize(360, 50);

4.

Add and implement click and event listeners

See sample project for more info.

Add Adserver field to screen

currentScreen.add (field)

Note: all downloading tasks will be performing after adding adserver control to the screen.

AdserverInterstitial control
:

1.

Create new AdserverInterstitial object:

AdserverInterstitial field = new AdserverInterstitial
(
8061, 16112
);

2.

Set optional parameters:

Similar to Adserver object

3.

Set ‘close’ button behavior
:

Auto close form time in ms:

field.

setAutoCloseInterstitialTime
(10
0
00)
;


‘Close’ button delay:

fied.

setShowCloseButtonTime
(2000)


‘close’ button will be shown after 2 second delay on
screen

Set ‘Clo
se’ button position on screen:

field.

.setCloseButtonPosition(AdserverInterstitial.CLOSEBUTTONPOSITIONCENTER);



Copyright © 2010 mOcean

Mobile. All Rights Reserved.

136 Baxter St, New York, NY 10013

Page
21


4.

Add interstitial form to display stack:

field.

.pushScreen();

Stopin
g

and refreshing Adserver content
:

Default update time = 12 sec. To set user defined update time


use setUpdateTime(int seconds)
method:

field.setUpdateTime(2);

To stop updating set update time to 0, to refresh it again set update time in seconds.

Update Ad content right now
:

If You don’t

want to wai
t

till the end of update time


use update() method.

Stopping and starting Ad update
:


To stop updating Ad content use setUpdateTime(0) method, to start updating again


use setUpdateTime(YOU_UPDATE_INTERVAL)