Android app embedded with Mi SDK tutorial

Source: Internet
Author: User

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:

  1. <? XML version = "1.0" encoding = "UTF-8"?>
  2. <Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android"
  3. Xmlns: umadsdk = "http://schemas.android.com/apk/res/net.youmi.helloyoumi"
  4. Android: Orientation = "vertical"
  5. Android: layout_width = "fill_parent"
  6. Android: layout_height = "fill_parent"
  7. >
  8. <Textview
  9. Android: layout_width = "fill_parent"
  10. Android: layout_height = "wrap_content"
  11. Android: textsize = "20px"
  12. Android: text = "@ string/hello"
  13. />
  14. <Net. youmi. Android. adview
  15. Android: Id = "@ + ID/ad"
  16. Android: layout_width = "fill_parent"
  17. Android: layout_height = "wrap_content"
  18. Umadsdk: refreshinterval = "30 ″
  19. Umadsdk: changeadanimation = "true"
  20. />
  21. </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:

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.