How to add ads to your Android app

Source: Internet
Author: User

How to add ads to your Android app

In the forum before the "Android Learning and how to make money using android " Post, received a lot of Android developers reply, Add to the blog in the reply, many people asked how to add ads in the application, today there is just a new small application to add ads, together to write a summary.

let me introduce what I have prepared:

Application:

"Popstar 2015", a simple familiar little game. Beautify the next interface, optimize the next operation process, we can from https://itunes.apple.com/us/app/xiao-chu-xing-xing-zhong-wen/id966179624?mt=8

Download to

In combination with the reality of the app, I'm going to add 3 modes of advertising here, the one I mentioned in the previous article, the ad wall and the push ad.

I'm going to add the pop-up menu (more apps and about 2 options) to the Settings button below the first photo-shoot button, display the ad wall in the more Apps menu, show an ad bar above the second graph interface, and push the ad because it doesn't occupy the ad interface, so don't worry about where it is. (Of course, when the final release I will be based on different publishing market to choose one of the 1-2 Types of advertising, this is only for demonstration purposes, too many ads will make users disgusted)

Advertising Platform:

Advertising wall and push ads I use Baidu, advertising strips I use Keymob's aggregation management tool, temporarily intends to use the wide-point, AdMob 2 platforms. (The reason to use multiple platforms can be done in real-time online proportional distribution, so there is more choice, of course, not the more the better, the more the platform, the more bloated the application, your income is of course scattered, and each platform requires at least Yuan to withdraw money. )

Let's start by adding ad walls and push ads.

1. Login to the Baidu platform, go to the Developer page, click Add App, enter the app name, click Save, then open the app details page, write down The value of waps_id 2 steps to use. The information in the back is also as perfect as possible .

File programs and so on the final completion of advertising integration and testing before uploading.

2. Add the permissions required for the ad under the androidmanifest.xml file of my project (specifically, which permissions to participate in the ad SDK the help and the actual situation will be ):

<uses-permission android:name= "Android.permission.READ_PHONE_STATE"/>
<uses-permission android:name= "Android.permission.INTERNET"/>
<uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name= "Android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name= "Android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name= "Android.permission.GET_TASKS"/>

Join in application :

<meta-data android:name= "waps_id" android:value= "2f9dd55307ede480a80ba0783be835d"/>
<meta-data android:name= "Waps_pid" android:value= "WAPs"/>
<activity android:name= "Com.waps.OffersWebView"
android:configchanges= "Keyboardhidden|orientation"/>

The first line android:value corresponding string to replace step 1 from the Baidu add application after the ID, do not fill the wrong oh.

The second line is Baidu Channel setup options, preferably according to its developer manual last corresponding form to fill in

The third line is the activityused to display the ad wall, and not adding it will cause the ad wall to be displayed .

3.eclipse->project->properties->java Build path->libraries->add External jars-> Select the extract from the previous download Appoffer_1.5.3.jar, to complete the add Baidu SDK jar package.
Add Appconnect.getinstance (this) to processing events that correspond to more application menus . showoffers (this); to open the ad wall.

Run the app, click More apps, open the recommended list

4. Open the entry Activity for the project and write it in the onCreate Event

Appconnect.getinstance (this);

Appconnect.getinstance (This). Getpushad (); Auto Push use , If you Configure auto push on Baidu Web side can comment the second line

Write to the place where the app was exited ( I was the OnDestroy event at the Ingress Activity )

Appconnect.getinstance (This). Finalize ();

To run a push effect such as:

Click Notifications ( push ad ) Open  

So we put Baidu's advertising wall and push mode of advertising integration, the application will use the official signature ( method Online Search Many, here does not introduce ) after compiling will apk Upload to Baidu Audit, at the same time can be released to the market channel to let users download. ( about market release in the next chapter )

The following describes the use Keymob aggregation to add an ad strip:

1. login to Keymob platform, add new app, play * must fill, click Next to enter the ad Platform Selection page.

2. Go to the ad platform you want to add to add a new app to get the corresponding id id 1 step keymob platform corresponding to id set (the point corresponds to the platform of the " not set " ).

3. click on the page, click the button on the back of the platform to open the status of the platform and tap open test so that you can then test to see if the test ad is available. Also 2 All platforms are proportional to 50%

4. Click Next and the app is finished. Will get a keymobid spare, download keymob advertising sdk (Because the sdk Span style= "font-family:arial;" >jar package, so there is no need to download the other ad platform separately, and the aggregation platform does not necessarily update all the platform's packages in a timely manner, may not change the ad platform updates in a timely manner sdk So it must also be from here)

5. unzip keymob sdk and libs , youmi-android.jar[ There are rice ] , domob_android_sdk.jar[ multi-union "

6. modify androidmanifest.xml file, add the necessary permissions, and to keymobsdk Span style= "font-family: the song Body;" > The development help document found the corresponding platform required to add the activity . I'm adding :

  <!--  multi-Union INTEGRATION&NBSP;-->
  <activity android:name= "cn.domob.android.ads.DomobActivity"
    Android:theme= "@android: Style/theme.translucent" &NBSP;/>
  <!--  There are meters INTEGRATION&NBSP;-->
  <activity android:name= "net.youmi.android.AdActivity"
   android: Configchanges= "Keyboard|keyboardhidden|orientation" &NBSP;/>
  <activity android:name= " Net.youmi.android.spotad.AdActivity "
   android:configchanges=" keyboard|keyboardhidden| Orientation "&NBSP;/>

7. Add keymobkey meta-data to replace the value you obtained at The end of the Keymob platform KEY value, my side is as follows:

<meta-data android:value= "25fff80a3966465e888e0db9735fef11" android:name= "Admogo_key"/>

8. Add the following code where you want to show it:

  admogolayout adview = new admogolayout (This, " 25fff80a3966465e888e0db9735fef11 ");  //id xml
  framelayout.layoutparams params = new framelayout.layoutparams (
   framelayout.layoutparams.wrap_content,
  framelayout.layoutparams.wrap_content);
  //  Set the location where the ad appears ( hover at top )
   params.topmargin = 0;
  params.gravity = gravity.top| Gravity.center_horizontal;
  addcontentview (adview, params);

This code works by creating a new Viewof the keymob ad and adding it to the top of the activity .

9.OK, the code is added to complete, run the test, the ad normal display as follows:

If you click on the test, you can open the Ad page normally. Go to the keymobweb page to adjust the distribution of your ad platform, and test all of your platforms for successful display. If there is a failure, verify that the ID or password configured on the keymob is the same ( including no spaces before and after ) . If you still have a problem, contact the platform technician to help you solve it.

The final step is to distribute the scale evenly on the Keymob Web page and turn off test mode. The app signature is then packaged and uploaded to each ad platform for review. ( the average distribution is for auditors to ensure they have the opportunity to see ads showing their platform on your app ), and audits can be posted to each market to start earning journeys.

The use of Keymob can be seen in the tutorial www.keymob.com/tutorial_zh/index.html

More detailed and complete

How to add ads to your Android app

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.