[Android operations] add admob ads to android applications

Source: Internet
Author: User
Tags admob

The latest Admob advertisement release process (in practice ):

Step One log on to admob and register a user

Log on to http://www.admob.com/and use the googleaccount number to log on.

After Step Two logs on to admobSites and ApplicationsOption

Select and add an android Application

Note:ApplicationsAfter, SetApplication advertisement settingsAnd record the publisher ID:11119a2c6ff2759 

Step Three download admob sdk

Http://code.google.com/intl/zh-CN/mobile/ads/download.html download path

Step Four unzipping SDK, the app loads the GoogleAdMobAdsSdk-4.1.1.jar In the sdk

Step Five adds advertisement (Code Method):

  • In the AndroidManifest. xml file

Join:

<Activity android: name = "com. google. ads. AdActivity"
Android: configChanges = "keyboard | keyboardHidden | orientation"
/>

// Permission section:
<Uses-permission android: name = "android. permission. INTERNET"/>
<Uses-permission android: name = "android. permission. ACCESS_NETWORK_STATE"/>
  • Set the space container to add the advertisement in the interface

     <LinearLayout 
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:minHeight="60px"
    android:id="@+id/mainLayout"
    android:orientation="vertical">
    </LinearLayout>
  • Set advertisement in Activity code

    /** Called when the activity is first created. */
private AdView adView;
// Create the adView
adView = new AdView(this, AdSize.BANNER, "a14e9a2c6ff2759");
// Lookup your LinearLayout assuming it’s been given
// the attribute android:id="@+id/mainLayout"
LinearLayout layout = (LinearLayout) findViewById(R.id.mainLayout);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad a
adView.loadAd(new AdRequest());



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.