׃整整一天时_研究怎么通过?font style="background-color: #00ffff;">Android应用E序中添加Admobq告来赚钱。网上也有些教程Q不q说得不够详l,自己q得花时间摸索。ؓ了让后来者能更快开始Admobq告赚钱Q所以写个详l一点的教程Q供大家参考?/p>
例子工程源码下蝲地址Q?使用览器自带的下蝲工具下蝲)http://cid-cb78b387364ae9a7.skydrive.live.com/browse.aspx/.Public/%e8%bd%af%e4%bb%b6/Andoroid
当然Q我也参考了一些网上的资料Q主要有Q?/p>
AdMobQ在android应用中嵌入广告的Ҏ
如何?font style="background-color: #00ffff;">Android Market赚钱 part 2 - 免费app附带q告
Publisher Starter Kit
面向开发?Wiki ?AdMob
好了Q现在让我从头开始说?#8230;…在这之前Q你不需要有M的帐P唯一需要的是有一个有效的email邮箱。只要按照下面的步骤一步步来,你就能通过Admob的广告插到自qE序中赚钱啦Q?/p>
首先Q当然是需要注册一个Admob的帐受Admob的主|Q?a >http://www.admob.com/ ?当然Q如果你对于览英文|页q有些障的话,可以d中文|站Q?a >http://zhcn.admob.com/
。如果网站的文字q是英文Q你可以在网站主늚右下角的“Language”处,选择“中文Q简体)”。点击进入注册页面后Q有一些栏目需要填写,不要?
q疑虑,像你注册一个论坛一P随便填下好了。最关键的是保证填写的email地址有效Q另外就是填上姓名,选择语言。帐L型我选择?#8220;不确?#8221;Q?
语言“中文Q简体)”?提交注册甌之后Q不久你׃收到用于认q激zdL电子邮gQ点Lz链接,可以了ȀzM的Admob帐号了~
W二步就是设|你?font style="background-color: #00ffff;">Android?
用程序信息,q获得Admob的插入代码。登录你的Admob帐号后,在主늚左上方(Logo上面Q点?#8220;MarketplaceQ手机广告市场)”Q?
q入面后,?#8220;Sites&AppsQ站点和应用E序Q?#8221;标签下,点击“Add Site/App”。选择我们熟悉的图标—? Android App ” 。这时会出现需要你填写一?#8220;详细信息”Q随便填上一些信息。(不要太过在意现在填写的东西,因ؓq些以后都是可以修改的)。比?#8220;Android Package URL” 我到现在都还没有填写Q描qCcȝQ想写就写点吧。填好详l信息后Q点?#8220;l箋”Q就可以到AdMob Android SDK 的下载页面了。下载这个SDKQ当Ӟq个很重要)?/p>
The AdMob Android SDK includes:
README: Get started with AdMob Android ads!
AdMob Jar file: Required for publishing ads. Follow the documentation in
javadoc/index.html and drop the AdMob Jar file into your project.
Sample Projects: Examples of AdMob Android ads shown in the LunarLander application.
W三步获取你的应用程序对应的Publisher ID。在下蝲面点击"Go to Sites/Apps"可以到你应用程序的理界面了。这时你会发现在q个面醒目的位|会有一个叫你填写详l信息的提示Q?/p>
在我们发送Q何有待收入之前,您需要填写技术联p详l信息和付款首选项?/p>
我们暂时可以不用它Q因为钱是会存在我们的Admob的̎户上的,{我们需要提现的时候,或者你惛_的时候再填就可以了。在下面的列表中Q选择?
的应用程序ƈq入。这个界面就是你的应用程序广告的理界面了,里面有比较多的功能,以后可以慢慢了解Q现在我们只需要知道两个东西,一个是发布?
IDQPublisher IDQ,一个是你程序的状态。Publisher
ID是一?5个字W的字符Ԍ而你E序的状态现在应该还是不zdQInactiveQ。我们下面要做的是怎么让它变ؓActive?/p>
W四步代码编写——在你的应用E序中插入Admobq告。经q上面的步骤Q我们在|站上的讄告一个段落了Q现在我们终于要q入主题了,如何在自qAndroid应用E序中插入Admobq告。如果你不健忘的话,一定还记得我们之前下蝲的那个AdMob Android SDK 。解压它Q看看里面有些什么东ѝ这里面最重要的就是那个名?#8220;admob-sdk-android.jar”的包啦,Admob如何把q告加蝲?font style="background-color: #00ffff;">Android应用E序中的代码集成在这个包里,我们~写E序的时候就需要将q个包导入到我们的工E里面去。另外,解压出来的文件夹中还有一个名?#8220;javadoc”的文件夹Q打开它里面的index.html。它是关于Admob Android SDK的帮助文档,在Package 下的Setup下,有详l完整的在自q应用E序中插入广告的Ҏ介绍Q在q里我就hQ引用一下~
Including the Jar
Add the Jar file included with the SDK to your Android
project as an external library. In your project's root directory create
a subdirectory libs (this will already be done for you if you used Android's activitycreator). Copy the AdMob Jar file into that directory. For Eclipse projects:
Go to the Properties of your project (right-click on your project from the Package Explorer tab and select Properties)
Select "Java Build Path" from left panel
Select "Libraries" tab from the main window
Click on "Add JARs..."
Select the JAR copied to the libs directory
Click "OK" to add the SDK to your android project
注意Q需要首先在你工E的根目录下新徏一个叫?#8220;libs”的文件夹Qƈ把之前所说的最重要的东?#8220;admob-sdk-android.jar”复制到里面?/p>
AndroidManifest.xml
Your AdMob publisher ID was given to you when creating your publisher account on www.admob.com
before downloading this code. It is a 15-character code like
a1496ced2842262. Just before the closing </application> tag add a
line to set your publisher ID:
<!-- The application's publisher ID assigned by AdMob -->
<meta-data android:value="YOUR_ID_HERE" android:name="ADMOB_PUBLISHER_ID" />
</application>
Set any permissions not already included just before the closing </manifest> tag:
<!-- AdMob SDK permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</manifest>
Only the INTERNET permission is required. Setting
ACCESS_COARSE_LOCATION (and/or ACCESS_FINE_LOCATION) allows narrowly
geo-targeted ads be shown.
q里需要注意的是,<meta-data android:value="YOUR_ID_HERE" android:name="ADMOB_PUBLISHER_ID"
/>中,我们只需要改的是"YOUR_ID_HERE"。这里需要你填上的ID是我们之前在Admob|站我们的应用程序管理页面上看到?
Publisher IDQ而name="ADMOB_PUBLISHER_ID"是不应该改的。程序需要这个Key来查扑֯应的Value?/p>
attrs.xml
The attrs.xml file specifies custom AdView attributes in XML layout
files. If your application does not already have an
/res/values/attrs.xml file then create one and copy-and-paste the
following into it. If you do have that file then just add the
declare-styleable element:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="com.admob.android.ads.AdView">
<attr name="testing" format="boolean" />
<attr name="backgroundColor" format="color" />
<attr name="textColor" format="color" />
<attr name="keywords" format="string" />
<attr name="refreshInterval" format="integer" />
<attr name="isGoneWithoutAd" format="boolean" />
</declare-styleable>
</resources>
q个Q没什么说的?/p>
Placing an AdView in a Layout
AdView widgets can be put into any XML layout now. The first step is to
reference attrs.xml in your layout element by adding an xmlns line that
includes your package name specified in AndroidManifest.xml:
xmlns:yourapp=http://schemas.android.com/apk/res/yourpackage
For example a simple screen with only an ad on it would look like:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:admobsdk="http://schemas.android.com/apk/res/com.admob.android.example"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
admobsdk:backgroundColor="#000000"
admobsdk:textColor="#FFFFFF"
admobsdk:keywords="Android application"
/>
</LinearLayout>
q里好像也没什么需要特别注意的Q注意加上xmlnsQ另外知道这里可以设|一个keywords
Test Mode
When you start integrating AdMob ads into your application it is
recommended to use test mode. This always returns the same ad. Normal ad
requests are not deterministic making it harder to be sure the ad view
looks like you want (e.g. ad requests can timeout or may not fill).
Once the ad shows up as you expect be sure to turn test mode off to get real ads. Never put your application into the Android Market with test mode enabled.
Test mode can be enabled either by calling
AdManager.setInTestMode(true) or by adding a "admobsdk:testing="true""
property to the ad in your XML layout (where "admobsdk" is the XML
namespace for your application).
讄Test Modeq个很关键,千万别将处于Test Mode的程序发布出MQ那样可赚不了钱啊~Q如果在AdView的属性中不加上admobsdk:testing="false"Q似乎程序也是不处于Test Mode的,不过最好还是加上吧?/p>
W五步编译运行,q激zȝ序。编译运行你的程序,在模拟器上就可以看到效果啦~Q当然你的模拟器需要能上网Q关于怎么让模拟器上网呢?用\q应该
可以直接上,如果不是用\由,那么可能需要设|下Q具体方法大家自q上搜吧,具体忘了Q。如果你的应用程序能昄出广告,那么恭喜你,你的应用E序很快
׃在Admob上被ȀzMQ需要一定的旉Q我的好像花了一个小时不刎ͼQ?/p>
W六步在Admob|站上查看应用程序赚了多钱?#8220;手机q告市场”?gt;“报告”?gt;“站点和应用程序报?#8221;。选择你的应用E序Q然后点击页面最下面?#8220;创徏报告”?OKQ赚钱啦?/p>
最后,我把我自己写的一个例子工E上传上来,大家可以下蝲来参考下。另外,我的工程广告作为移动的Qƈ且改变了它默认的宽度和背景,希望对如何在应用E序中摆攑ֹ告,起到一个抛砖引玉的作用。效果图如下Q哈哈,在模拟器跑的~)Q?/p>
1.http://www.admob.com/注册一个帐P
dAdd Mobile Site/appQ输入相关信息后Q提交完成,
下蝲Androidq_使用的JARQ查看发布?ID?/p>
2.然后JARdC的项目中
Properties->Java Build Path->Libraries->Add JARs…->Select the JAR->OK
3.~辑AndroidManifest.xml
application节点中添?/p>
<!– The application’s publisher ID assigned by AdMob –>
<meta-data android:value=”a14ae1ce0357305″ android:name=”ADMOB_PUBLISHER_ID” />
manifest节点d权限甌
<!– AdMob SDK permissions –>
<uses-permission android:name=”android.permission.INTERNET” />
4.dattrs.xml
/res/values/attrs.xml
<?xml version=”1.0″ encoding=”utf-8″?>
<resources>
<declare-styleable name=”com.admob.android.ads.AdView”>
<attr name=”testing” format=”boolean” />
<attr name=”backgroundColor” format=”color” />
<attr name=”textColor” format=”color” />
<attr name=”keywords” format=”string” />
<attr name=”refreshInterval” format=”integer” />
<attr name=”isGoneWithoutAd” format=”boolean” />
</declare-styleable>
</resources>
5.dq告lg
<?xml version=”1.0″ encoding=”utf-8″?>
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
xmlns:admobsdk=”http://schemas.android.com/apk/res/com.moandroid.livesports”
android:orientation=”vertical”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
>
<TextView
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”@string/hello”
/>
<com.admob.android.ads.AdView
android:id=”@+id/ad”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
admobsdk:backgroundColor=”#000000″
admobsdk:textColor=”#FFFFFF”
admobsdk:keywords=”Android application”
admobsdk:refreshInterval=”60″
/>
</LinearLayout>
6.昄效果
为免费app嵌入Admobq告Q进而获得广告收入?/p>
