1: register the user and download the jar package: Go
Http://www.youmi.net/register an account and then add an application
2: Configure in the manifest. xml file:
<Uses-Permission Android: Name = "android. Permission. Internet"/>
3: Add the following in your activity type:
// Use static methods to initialize admanager and set the appid, password, AD request interval, and
// Test mode and other parameters.
Static {
// The first parameter is appid.
// The second parameter is the application password.
// The third parameter is the request interval. The valid value ranges from 30 to 200, in seconds.
// The fourth parameter is to set the test mode. If it is set to true, there is no advertisement display or click record
// Effect, run in test mode. When set to false, the display and point of the advertisement
// The hit record is valid and runs in release mode. Set it to false.
Admanager. INIT ("df587cb8a2c2a013", "ef967beb5489644e ",30, false );
Appid and app password are what you get after adding app in http://www.youmi.net
4: Add attrs. XML to the res/values folder.
The content of the attrs. xml file is as follows:
<? XML version = "1.0" encoding = "UTF-8"?>
<Resources>
<Declare-styleable name = "net. youmi. Android. adview">
<ATTR name = "backgroundcolor" format = "color"/>
<! -- Solid color background color of advertisement bar -->
<ATTR name = "startbackgroundcolor" format = "color"/>
<! -- The starting color of the gradient background color of the advertisement bar -->
<ATTR name = "endbackgroundcolor" format = "color"/>
<! -- The ending color of the gradient background color of the advertisement bar -->
<ATTR name = "clickbackgroundcolor" format = "color"/>
<! -- Background color when an ad bar is clicked -->
<ATTR name = "textcolor" format = "color"/>
<! -- Font color -->
<ATTR name = "backgroundtransparent" format = "integer"/>
<! -- Background transparency -->
</Declare-styleable>
</Resources>
5: layout the rice advertisement view in Main. xml.
The following is an instance:
<? XML version = "1.0" encoding = "UTF-8"?>
<Linearlayout
Xmlns: Android = "http://schemas.android.com/apk/res/andro
ID"
Xmlns: umadsdk = "http://schemas.android.com/apk/res/net.y
Oum I. helloyoumi"
Android: Orientation = "vertical"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
>
<Textview
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content
"Android: textsize =" 20px"
Android: text = "@ string/hello"
/>
<Net. youmi. Android. adview
Android: Id = "@ + ID/ad"
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Umadsdk: textcolor = "#0fff22"
Umadsdk: backgroundtransparent = "155"
Umadsdk: startbackgroundcolor = "# 2b2b2b"
Umadsdk: endbackgroundcolor = "# 63b8ff"
Umadsdk: clickbackgroundcolor = "# 1e90ff"
/>
</Linearlayout>
Note:
Xmlns: umadsdk = "http://schemas.android.com/apk/res/net.youmi.H
Ell oyoumi"
This sentence must be added, or an error will be prompted. Net. youmi. helloyoumi is your application package.
Name
6: Always reload ondestroy () in the activity with the ad Control ()
And call adview. ondestroy ().
@ Override
Protected void ondestroy (){
// Todo auto-generated method stub
Super. ondestroy ();
Try {
Adview = (adview) findviewbyid (R. Id. AD );
If (adview! = NULL)
{
Adview. ondestroy ();
}
} Catch (exception e ){
// Todo: handle exception
}
}