skip to main |
skip to sidebar
RSS Feeds
Nope. nothing .. just some random thoughts come to my mind ...
Nope. nothing .. just some random thoughts come to my mind ...
12:58 PM | Thursday, November 17, 2011
Posted by harshadura
Ref : http://android.jmsliu.com/209/add-google-admob-in-android-application.html
______________________
Admob is a new way to monetize mobile applications. Currently,
it supports multi-platform, including iPhone, Android, WebOS, and Flash
Lite. Here I will show you how to integrate Admob in your android
applications.
First, we need to go to the Admob website to register an account, in order to get the Admod account ID.
Second, let’s go the google code to download the latest Google AdMob Ads SDK
for android. You also can get download it from your admob “Sites &
Apps” setting page. After we get the AdMob SDK, we need to add the jar
in our android application Build Path. Then, you just need to put some
simple codes to show your ads in your applications.
1. For Admob, it’s better to add the com.google.ads.AdActivity in your Manifest.xml file. And don’t forget to add the user permission for it. Below is my mainfest.xml example.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| <? xml version = "1.0" encoding = "utf-8" ?> < manifest xmlns:android = "http://schemas.android.com/apk/res/android" package = "com.jms.AdmobExample" android:versionCode = "1" android:versionName = "1.0" > < uses-sdk android:minSdkVersion = "8" /> < application android:icon = "@drawable/icon" android:label = "@string/app_name" > < activity android:name = ".AdmobExample" 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" /> </ application > < uses-permission android:name = "android.permission.INTERNET" /> < uses-permission android:name = "android.permission.ACCESS_NETWORK_STATE" /> </ manifest > |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| <? xml version = "1.0" encoding = "utf-8" ?> < LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android" android:orientation = "vertical" android:layout_width = "fill_parent" android:layout_height = "fill_parent" > < ImageView android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:src = "@drawable/a" /> < com.google.ads.AdView xmlns:ads = "http://schemas.android.com/apk/res/com.jms.AdmobExample" android:id = "@+id/adView" android:layout_width = "fill_parent" android:layout_height = "fill_parent" ads:adSize = "BANNER" ads:adUnitId = "a14dbba084368db" /> </ LinearLayout > |
1
2
3
4
5
6
7
8
9
10
11
12
| <? xml version = "1.0" encoding = "utf-8" ?> < resources > < declare-styleable name = "com.google.ads.AdView" > < attr name = "adSize" > < enum name = "BANNER" value = "1" /> < enum name = "IAB_MRECT" value = "2" /> < enum name = "IAB_BANNER" value = "3" /> < enum name = "IAB_LEADERBOARD" value = "4" /> </ attr > < attr name = "adUnitId" format = "string" /> </ declare-styleable > </ resources > |
1
2
3
4
5
| AdView adview = (AdView)findViewById(R.id.adView); AdRequest re = new AdRequest(); re.setTesting( true ); re.setGender(AdRequest.Gender.FEMALE); adview.loadAd(re); |
October 6, 2016 at 1:50 PM
If you are looking for a good contextual advertising company, I suggest that you take a peek at Chitika.