Step 1 :- Get site id From your account like a151fa47259f783.
Step 2 :- Create new Project implement for ads.
Step 3 :- ADD Permission in manifest file in your project.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Step 4 :- add activity in application at manifest file.
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
Step 5 :- Finally manifest file look like this.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ad_mob"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<activity
android:name="com.example.ad_mob.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Step 6 :- Add GoogleAdMobAdsSdk-6.4.1.jar in your lib folder at your projects.
Step 7 :- Add main.xml
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/web"
android:layout_width="fill_parent"
android:layout_height="50sp"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="a151fa47259f783"
android:background="@android:color/transparent" />
Step 8 :- open main.java file and add this code.
AdView adview = (AdView)findViewById(R.id.web);
AdRequest re = new AdRequest();
adview.loadAd(re);
Step 9 :- Run this code.
Out/Put
Download link : - https://dl.dropboxusercontent.com/u/109954727/admob.zip
Step 2 :- Create new Project implement for ads.
Step 3 :- ADD Permission in manifest file in your project.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Step 4 :- add activity in application at manifest file.
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
Step 5 :- Finally manifest file look like this.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ad_mob"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<activity
android:name="com.example.ad_mob.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Step 6 :- Add GoogleAdMobAdsSdk-6.4.1.jar in your lib folder at your projects.
Step 7 :- Add main.xml
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/web"
android:layout_width="fill_parent"
android:layout_height="50sp"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="a151fa47259f783"
android:background="@android:color/transparent" />
Step 8 :- open main.java file and add this code.
AdView adview = (AdView)findViewById(R.id.web);
AdRequest re = new AdRequest();
adview.loadAd(re);
Step 9 :- Run this code.
Out/Put
Download link : - https://dl.dropboxusercontent.com/u/109954727/admob.zip
Nice One.....
ReplyDeleteplz update your demo thanks!
ReplyDelete