Start AdMob advertising profit model detailed tutorial

Source: Internet
Author: User
Tags directory create valid email address admob

It took a whole day to study how to make money by adding AdMob ads to Android applications. There are also some tutorials on the Internet, but they are not detailed enough and you have to spend time exploring them. In order to allow later users to start AdMob advertising to make money faster, write a detailed tutorial for your reference.

ExampleSource code download address: Download source code

Of course, I have also referred to some online materials, mainly including:

AdMob: An advertisement embedding solution in Android applications
How to make money in the Android Market Part 2-free app with ads
Publisher Starter Kit
AdMob for developer Wiki

Now let me start from the beginning ...... Before that, you don't need any account. The only thing you need is a valid email address. As long as you follow the steps below, you can make money by inserting the AdMob advertisement into your own program!

First, you must register an AdMob account. AdMob home page is: http://www.admob.com /. Of course, if you still have some obstacles to browsing the English web page, you can log on to the Chinese website: http://zhcn.admob.com /. If the website text is still in English, you can select "Chinese (simplified)" in the "language" area in the lower-right corner of the home page )". After you click to enter the registration page, you need to enter some topics and do not worry too much, just like you registered a forum, just fill it out. The most important thing is to ensure that the entered email address is valid. The other is to fill in the name and select the language. The Account type I selected is "not sure", and the language is "Chinese (simplified )"~ After you submit a registration application, you will soon receive an email to confirm and activate your account. Click the activation link to activate your AdMob account ~

Step 2: Set your android application information and obtain the AdMob insertion code. After logging on to your AdMob account, click "Marketplace (mobile advertising market)" in the upper-left corner of the homepage. after entering the page, go to "sites & apps (sites and applications) click Add site/app ". Select the familiar icon "Android app ". In this case, you need to enter a "details" and enter some information at will. (Do not care too much about what you enter, because these can be modified later ). For example, "android package URL" has not been filled in yet, and the description is similar. If you want to write it, write it. After filling in the details, click "continue" To Go To The AdMob Android SDK download page. Download this SDK (of course, this is important ).

The AdMob Android SDK uplodes:

Readme: get started with AdMob Android ads!
AdMob JAR file: Required for Publishing ads. Follow the documentation in javadoc/index.html and drop the AdMob JAR file into your project.
Sample projects: Examples of AdMob Android ads shown in the lunarlander application.

Step 3: Obtain the publisher ID corresponding to your application. On the download page, click "go to sites/apps" To Go To The Application Management page. At this time, you will find a prompt asking you to fill in the details in a prominent position on this page:

You need to fill in the technical contact details and payment preferences before we send any pending income.

We don't need to worry about it for the time being, because the money will be stored in our AdMob account. You can just fill it out when we need to withdraw the money, or when you want to fill it out. In the list below, select your application and enter. This interface is the management interface for your application advertisement. It has many features and will be easy to understand later. Now we only need to know two things, one is the publisher ID and the other is the state of your program. Publisher ID is a 15-character string, and the state of your program should still be inactive ). The following is how to make it active.

Step 4: code writing-insert AdMob ads in your application. After the above steps, we have a section on the website, and now we have to enter the topic, how to insert AdMob ads in our Android Application. If you are not forgetful, remember the AdMob Android SDK we downloaded before. Decompress it and see what is in it. The most important thing here is the package named "admob-sdk-android.jar", AdMob will integrate the code that loads the advertisement into the Android Application into this package, when writing a program, we need to import this package into our project. In addition, the decompressed folder contains a file named "“javadocloud", and the corresponding index.html is opened. It is a help document for AdMob Android SDK. Under setup under package, we have detailed and complete instructions on how to insert advertisements in our own applications. Here I am lazy, reference ~

Including the jar

Add the JAR file encoded with the SDK to your android project as an external library. in your project's root directory create a subdirectory libs (this will already be done for you if you used Android's activitycreator ). copy the AdMob JAR file into that directory. for eclipse projects:

Go to the properties of your project (right-click on your project from the package explorer tab and select Properties)
Select "Java build path" from left panel
Select "Libraries" tab from the main window
Click on "add jars ..."
Select the jar copied to the libs directory
Click "OK" to add the SDK to your android Project

Note: first create a folder named "Libs" under the root directory of your project, and copy the most important thing "admob-sdk-android.jar" that was previously mentioned to it.

Androidmanifest. xml

Your AdMob publisher ID was given to you when creating your publisher account on www.admob.com before downloading this code. it is a 15-character code like a1496ced2842262. just before the closing </Application> tag add a line to set your publisher ID:

<! -- The application's publisher ID assigned by AdMob -->
<Meta-data Android: value = "your_id_here" Android: Name = "admob_publisher_id"/>
</Application>

Set any permissions not already included just before the closing </manifest> tag:

<! -- AdMob SDK permissions -->
<Uses-Permission Android: Name = "android. Permission. Internet"/>
<Uses-Permission Android: Name = "android. Permission. access_coarse_location"/>
</Manifest>

Only the Internet permission is required. Setting access_coarse_location (and/or access_fine_location) allows narrowly geo-targeted ads be shown.

Note that, in <meta-data Android: value = "your_id_here" Android: Name = "admob_publisher_id"/>, we only need to change it to "your_id_here ". The ID you need to fill in here is the publisher ID we saw on our application management page on the AdMob website, and name = "admob_publisher_id" should not be changed. The program needs this key to find the corresponding value.

Attrs. xml

The attrs. XML file specifies custom adview attributes in XML layout files. if your application does not already have an/RES/values/attrs. XML file then create one and copy-and-paste the following into it. if you do have that file then just add the declare-styleable element:

<? XML version = "1.0" encoding = "UTF-8"?>
<Resources>
<Declare-styleable name = "com. AdMob. Android. Ads. 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"/>
</Declare-styleable>
</Resources>

That's nothing to say.

Placing an adview in a Layout

Adview widgets can be put into any XML layout now. The first step is to reference attrs. XML in your layout element by adding an xmlns line that contains des your package name specified in androidmanifest. xml:

Xmlns: yourapps = http://schemas.android.com/apk/res/yourpackage

For example a simple screen with only an ad on it wowould look like:

<? XML version = "1.0" encoding = "UTF-8"?>
<Linearlayout
Xmlns: Android = "http://schemas.android.com/apk/res/android"
Xmlns: admobsdk = "http://schemas.android.com/apk/res/com.admob.android.example"
Android: Orientation = "vertical"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent">

<Com. AdMob. Android. Ads. adview
Android: Id = "@ + ID/ad"
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Admobsdk: backgroundcolor = "#000000"
Admobsdk: textcolor = "# ffffff"
Admobsdk: KEYWORDS = "Android Application"
/>

</Linearlayout>

There seems to be nothing to pay special attention to here. Pay attention to adding xmlns, And you can set a keywords here.

Test Mode

When you start integrating AdMob ads into your application it is recommended to use test mode. this always returns the same ad. normal ad requests are not deterministic making it harder to be sure the ad view looks like you want (e.g. ad requests can timeout or may not fill ).

Once the AD shows up as you need CT be sure to turn test mode off to get real ads.Never put your application into the Android Market with test mode enabled.

Test mode can be enabled either by calling admanager. setintestmode (true) or by adding a "admobsdk: Testing =" true "" property to the ad in your xml layout (where "admobsdk" is the XML namespace for your application ).

It is critical to set the test mode. Do not release the program in the test mode. This will make no money ~! If admobsdk: Testing = "false" is not added to the adview attribute, it seems that the program is not in the test mode, but it is best to add it ~

Step 5 compile and run the program and activate the program. Compile and run your program. You can see the effect on the simulator ~ (Of course, your simulator needs to be able to access the Internet. How can you enable the simulator to access the Internet? You can use a route directly. If you do not use a route, you may need to configure it. You can search for it on the Internet by yourself, but forget it ). If your application displays ads, congratulations, your application will soon be activated on AdMob (it takes some time, I seem to have spent less than an hour )!

Step 6: view the amount of money your application has earned on the AdMob website ~ "Mobile advertising market"-> "report"-> "site and application report ". Select your application and click "Create report" at the bottom of the page "~ OK. Make money ~

Finally, I uploaded an example project I wrote. You can download it for reference. In addition, my project uses advertisements as mobile devices and changes the default width and background of advertisements, hoping to play a leading role in how to place advertisements in applications. As follows (haha, running in the simulator ~) :

 

Download example project source code:Download source code

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.