Android tips: How to insert Baidu ads in Android apps

Source: Internet
Author: User

1. Introduce

Now the ads in the game have basically become an important source of revenue for game creators. In fact, the insertion of advertising is quite simple, this article chose the Baidu Advertising Alliance as a case (always feel that Baidu will not pay wages). Note: However, the insertion of the ad program will be a little bit more card, and really very traffic.

(This article is not copy Baidu's document, will be very straightforward OH)

2. The Code section

First of all must be registered Baidu Advertising Alliance account, and download SDK. Address: http://munion.baidu.com/

The second step is to open Eclipse and import the inside jar file into the library.

Copy the jar package from Baidu to the Libs directory of your project, and import it in the following steps:

Right-click on your project and choose Properties.

Select Java build Path on the left side of the Project Properties dialog box.

In the Project Properties dialog box main window select "Libraries";

Click "Add JARs", add Baidu to promote jar package.

(In fact, I tried, directly copy the jar paste into Lib can also)

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/

The third step is to modify the permissions in the Androidmainfest.xml. (Annotated place is the place to add)

<?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-SDK android:minsdkversion= "8" android:targetsdkversion= "a"/> <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-perm Ission android:name= "Android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name= "Android.perm" Ission.  
    Access_coarse_location "/> <uses-permission android:name=" Android.permission.WRITE_EXTERNAL_STORAGE "/>" <uses-permission android:name= "Android.permission.ACCESS_WIFI_STATE"/></span> <appl Ication Android:allOwbackup= "true" android:icon= "@drawable/ic_launcher" android:label= "@string/app_name" Android:them E= "@style/apptheme" > <span style= "color: #3366ff" ><meta-data android:name= "baidumobad_app_id" Androi d: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:c onfigchanges= "Keyboard|keyboardhidden|orientation"/> </span> <activity and Roid:name= "com.example.adtest.MainActivity" android:label= "@string/app_name" > <intent-fil ter> <action android:name= "Android.intent.action.MAIN"/> <categor  
    Y android:name= "Android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application&gT </manifest>

The permission area is filled with permissions. Meta-data is to add Baidu account, we suggest that the value of debug for debugging, debug the end of their own.

<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 "Upload Application" on the image above to see the "Application Version list" below

The fourth step, Baidu provides a variety of advertising models, where the choice of roulette, feeling is the simplest kind. is to modify it in creat ().

@Override
    protected 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 Download Address

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.