Welcome to the android SDK of youmi advertising platform. The following describes how to embed youmi advertising in Android programs.
Step 1:Import youmiad-android.jar into your project.
Ø right-click your project root directory and select "properties"
Ø select "Java build path" on the left panel"
Then select the "Libraries" tab.
Ø click "add external jars ..."
Select the directory path for the youmiad-android.jar
Ø click "OK". The import is successful.
Step 2:Add the following code to androidmanifest. XML in the project and write your app ID and app secret.
<! -App ID and app seceret of the application
->
<Meta-data Android: value ="Abcdef1234567890 ″Android: Name ="Umad_app_sec"/>
<Meta-data Android: value ="1234567890abcdef"
Android: Name ="Umad_app_id"/>
</Application>
<! -Youmi advertisement SDK permissions->
<Uses-Permission Android: Name ="Android. Permission. Internet"/>
Note:Umad_app_idIt is the release ID of your application, and you just need to fill in your release ID in the value, so it is"1234567890 abcdef". Never change"Umad_app_id", The program needs this key to find the corresponding value ."Umad_app_sec"Likewise.Umad_app_idAndUmad_app_secThese two IDs are the release IDs and application passwords generated when the application is submitted on the platform website, and each application has a unique ID.
Step 3:Add attrs. XML to the res/values folder. If this file is not added, you cannot set the adview attribute in layout.
The content of the attrs. xml file is as follows:
<? XML version =1.0 ″Encoding =UTF-8 ″?>
<Resources>
<Declare-styleablename ="Net. youmi. Android. adview">
<ATTR name ="Testing"Format ="Boolean"/>
<ATTR name ="Backgroundcolor"Format ="Color"/>
<ATTR name ="Textcolor"Format ="Color"/>
<ATTR name ="Keywords"Format ="String"/>
<ATTR name ="Refreshinterval"Format ="Integer"/>
<ATTR name ="Isgonewithoutad"Format ="Boolean"/>
<ATTR name ="Changeadanimation"Format ="Boolean"/>
</Declare-styleable>
</Resources>
Note:
Ø testing: test mode. If it is in the debugging program, it is recommended to set it to "true", but it must be set to false before releasing the program. The default value is false.
Ø backgroundcolor: Set the background color of the AD view.
Ø textcolor: Set the color of ad text
Ø refreshinterval: Set the advertising refresh rate. The default value is 30 s. The value ranges from 30 s to 200 s.
Ø changeadanimation: the effect of changing an advertisement. If it is true, it is flipped; if it is false, it is fade in and out.
Step 4:The rice advertisement view is displayed in Main. xml.
The following is an instance:
- <? XML version = "1.0" encoding = "UTF-8"?>
- <Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android"
- Xmlns: umadsdk = "http://schemas.android.com/apk/res/net.youmi.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: refreshinterval = "30 ″
- Umadsdk: changeadanimation = "true"
- />
- </Linearlayout>
Note:
Xmlns: umadsdk ="Http://schemas.android.com/apk/res/net.youmi.helloyoumi"
This sentence must be added, or an error will be prompted. WhereNet. youmi. helloyoumiIs the name of your application package
To show that the rice advertisement is successfully added: