How Android Apps Add ads

Source: Internet
Author: User

Today's many Android game software, game software inserted ads is a game advertising manufacturers an important source of income, this article on the Baidu Alliance advertising as an example, add code method.

The first step:

Register for the Baidu affiliate account, and download the SDK. Address: The second step, open eclipse, the inside of the jar file into the library. &nbsp. Copy the jar package from Baidu to your project's Libs directory and import it as follows: Right click on your project and select "Properties"; on the left side of the Project Properties dialog box, select "Javabuild path" In the main window of the Project Properties dialog box, select "Libraries", click "Add jars", add the Baidu promotion jar package. (In fact, I tried, directly copy the jar pasted into the Lib can also) the third step, in the Androidmainfest.xml to modify permissions, and so on. (where annotated is the place to add) [java]<?xml version= "1.0"  encoding= "Utf-8"? ><manifest xmlns:android= " Http://schemas.android.com/apk/res/android "package=" Com.example.adtest "android:versioncode=" 1 "android: Versionname= "1.0"  ><uses-sdkandroid:minsdkversion= "8" android:targetsdkversion= " /><" span style= "COLOR: #ff6666" ><uses-permission android:name= "Android.permission.INTERNET"  / > </span><span style= "COLOR: #ff6666" ><uses-permission android:name= " Android.permission.READ_PHONE_STATE " /><uses-permission android:name=" Android.permission.ACCESS_NETWORK_STATE " /><uses-permission android:name=" Android.permission.ACCESS_COARSe_location " /><uses-permission android:name=" Android.permission.WRITE_EXTERNAL_STORAGE "  /><uses-permission android:name= "Android.permission.ACCESS_WIFI_STATE"  /></span>< Applicationandroid:allowbackup= "true" android:icon= "@drawable/ic_launcher" android:label= "@string/app_name" Android:theme= "@style/apptheme"  ><span style= "color: #3366ff" ><meta-data android: Name= "baidumobad_app_id"  android:value= "Debug"  /><meta-data android:name= "BaiduMobAd_APP_ SEC " android:value=" Debug " /></span> <span style=" Color: #33ff33 ">< Activity android:name= "com.baidu.mobads.AppActivity" android:configchanges= "keyboard|keyboardhidden| Orientation " /></span><activityandroid:name=" com.example.adtest.MainActivity "android:label=" @ String/app_name " ><intent-filter><action android:name=" Android.intent.action.MAIN "  /><category android:Name= "Android.intent.category.LAUNCHER"  /></intent-filter></activity></application> The </manifest>permission area is filled with permissions. Meta-data is to add Baidu's account, the recommended value is debug for debugging, debugging, after the change to their own. [java]<span style= "Color:rgb (51,255,51)" ><activity android:name= " Com.baidu.mobads.AppActivity "android:configchanges=" Keyboard|keyboardhidden|orientation " /></span > area can be added directly. Get Appsid and Appsec. Click on the "Upload app", you can see the "app version list" Fourth step, Baidu offers a variety of advertising models, here choose * * *, feeling is the simplest one. is modified in creat (). [Java] @Overrideprotected  void oncreate (bundle savedinstancestate)  {super.oncreate ( Savedinstancestate); Setcontentview (R.layout.activity_main); Relativelayout rlmain=new relativelayout (this); Setcontentview (Rlmain);iconsad iconsad=new  Iconsad (this); Iconsad.loadad (this);} Source code has been fully provided, ad placement depends on the code of different


How Android Apps Add ads

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.