Thursday, January 10, 2013

How-to Install Google AdMob 6.x into Android Apps

STEP 1: Register yourself as a user at http://admob.com . Login and create a site

admob in android app
  













admob in android app


setting site in admob


setting site in admob


setting site in admob


setting site in admob -publisher ID


STEP 2: Download the AdMob SDK currently SDK 6.1.0

make money from your android app


make money from your android app

STEP 3: Add an External JAR (library) in the project.

Copy GoogleAdMobAdsSdk-6.1.0.jar into libs

adding admob on android app


adding admob on android app

image



STEP 4: Additional details in the AndroidManifest.xml

Open your AndroidManifest.xml and add this lines to the <application> properties;

<activity android:name="com.google.ads.AdActivity"
   android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

Next, add these  <uses-permission>

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
 

And the meta-data attributes;
<meta-data android:value="true" android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" />

And the complete AndroidManifest.xml;
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="net.kerul.peribahasa"
    android:versionCode="7"
    android:versionName="1.07" >

    <uses-sdk android:minSdkVersion="8" />

    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name" >
        <activity
            android:name=".PeribahasaActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            
        </activity>
          <activity android:name="com.google.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
            
    </application>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <meta-data android:value="true" android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" />
</manifest>




STEP 5: Adding the AdView widget in the screen

   1: <TableRow
   2:     android:id="@+id/tableRow2"
   3:     android:layout_width="match_parent"
   4:     android:layout_height="wrap_content" >
   5:     <com.google.ads.AdView
   6:         xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
   7:         android:id="@+id/ad"
   8:         android:layout_width="fill_parent"
   9:         android:layout_height="wrap_content"
  10:         ads:adSize="SMART_BANNER"
  11:         ads:adUnitId="738a44d913034b9f"
  12:         />    
  13: </TableRow>


STEP 6: Adding the adView in the source code.

   1: public class PeribahasaActivity extends Activity implements OnClickListener{
   2:     protected EditText txtsearch;
   3:     protected Button btnocr, btnkamus, btnsearch,btncadang;
   4:     //protected Button btnpaste,btntaipinput;
   5:     protected WebView webview1;
   6:     protected String serverurl;
   7:     protected AdView adView;
   8:     /** Called when the activity is first created. */
   9:     @Override
  10:     public void onCreate(Bundle savedInstanceState) {
  11:         super.onCreate(savedInstanceState);
  12:         setContentView(R.layout.main);
  13:         
  14:         //admob widget
  15:         adView = (AdView)findViewById(R.id.ad);
  16:         adView.loadAd(new AdRequest());
 



























































































































No comments:

Post a Comment