The main channels of app monetization are advertising, value-added services, online trading. Recent projects need to be connected to Google's AdMob ad platform, which is a summary for other developers to refer to.
The first step: Download Google Play services Lib via Android SDK manager, how to download, Baidu, to download the other people provide
Once downloaded, reference the LIB project to the test project study to invoke the API for Google Play services-related ads
The second step, https://www.google.com/admob/registered account, after the registration is completed, you can create a new application to make a profit, I have tested the $0.13 here.
Note The AD unit ID that you created, and then we'll use the
Step Three: Androidmanifest.xml add permissions, Meta-data, Adactivity
<?xml version= "1.0" encoding= "Utf-8"? ><manifest xmlns:android= "http://schemas.android.com/apk/res/ Android "package=" Com.google.android.gms.example.bannerexample "> <!--Include required permissions for Google Mobile Ads to run--> <uses-permission android:name= "Android.permission.INTERNET"/> <uses-permission and Roid:name= "Android.permission.ACCESS_NETWORK_STATE"/> <application android:allowbackup= "true" Andro id:icon= "@drawable/ic_launcher" android:label= "@string/app_name" android:theme= "@style/apptheme" > <!--this meta-data tag was required to use Google Play services.--> <meta-data android:name= "com.google.an Droid.gms.version "android:value=" @integer/google_play_services_version "/> <activity android:name= "com.figo.study.AdmobActivity" Android : Theme= "@android: Style/theme.notitlebar" > <intent-filter> <action android:name= " Android.intent.action.MAIN "/> <category android:name=" Android.intent.category.LAUNCHER "/> </intent-filter> </ Activity> <!--Include the adactivity configchanges and theme. --<activity android:name= "com.google.android.gms.ads.AdActivity" android:configchanges= "keyboard |keyboardhidden|orientation|screenlayout|uimode|screensize|smallestscreensize "Android:theme=" @android: style/Th Eme. Translucent "/> </application></manifest>
Fourth Step: Design test page
<?xml Version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android" xmlns:ads= "Http://schemas.android.com/apk/res-auto" android:layout_width= "Match_parent" android:layout_height= " Match_parent "android:orientation=" vertical "> <textview android:layout_width=" wrap_content "and roid:layout_height= "Wrap_content" android:text= "@string/hello_world"/> <com.google.android.gms.ads.adview Android:id= "@+id/adview" android:layout_width= "match_parent" android:layout_height= "Wrap_content" Ads:adsize= "Smart_banner" ads:adunitid= "@string/banner_ad_unit_id" > </com.google.android.gms.ads.adv Iew></linearlayout>
The banner_ad_unit_id here is the ad unit ID for the app created in AdMob, configured in the Res/values/strings.xml file
<string name= "banner_ad_unit_id" >ca-app-pub-2128163432248238/6211350109</string>
Fifth step: Call in Activity
* */package Com.figo.study;import Android.app.activity;import Android.os.bundle;import Com.google.android.gms.ads.adrequest;import com.google.android.gms.ads.adview;/** * @author Figo * */public class Admobactivity extends Activity {@Overrideprotected void onCreate (Bundle savedinstancestate) {//TODO auto-generated Method Stubsuper.oncreate (Savedinstancestate); Setcontentview (r.layout.activity_admob); try {//banner ad Adview Madview = ( AdView) Findviewbyid (R.id.adview); Adrequest adrequest = new Adrequest.builder (). build ();//Madview.setadsize (Adsize.full_banner); Madview.loadad ( Adrequest);//interstitial AD//final Interstitialad interstitial = new Interstitialad (//Admobactivity.this);// Interstitial.setadunitid (getString (r.string.banner_ad_unit_id));//if (interstitial.isloaded ()) {// Interstitial.show ();////} else {//Adrequest adrequest = new Adrequest.builder (). build ();//Interstitial.loadad ( adrequest)//Adlistener Adlistener = new Adlistener () {////@Override//public void onadloaded () {//// TODO auto-generated Method stub//super.onadloaded ();//Interstitial.show ();//}//};//Interstitial.setadlistener ( Adlistener),//}} catch (Exception e) {System.out.print (E.getstacktrace ());}}}
OK, done, run effect:
Provide Google AdMob's official access documentation by the way
AdMob Website: https://apps.admob.com
AdMob Open Reference Document: https://developers.google.com/mobile-ads-sdk/
Quick Start: Https://developers.google.com/mobile-ads-sdk/docs/admob/android/quick-start
SDK Download: https://developers.google.com/mobile-ads-sdk/download
AdMob Reference Demo Download: Https://github.com/googleads/googleads-mobile-android-examples
Android Development 55:google AD Platform AdMob Access summary