WEB开发网
开发学院手机开发Android 开发 AdMob:在android应用中嵌入广告的方案 阅读

AdMob:在android应用中嵌入广告的方案

 2010-06-03 16:04:00 来源:WEB开发网   
核心提示:< uses-permission android:name="android.permission.READ_PHONE_STATE" / >< uses-permission android:name="android.permission.ACCESS_COARSE

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

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

< /manifest >

Only the INTERNET permission is required. Setting READ_PHONE_STATE is highly recommended because it identifies the user letting a greater variety of more relevant ads be chosen. Finally setting ACCESS_COARSE_LOCATION (and/or ACCESS_FINE_LOCATION) will let geo-targeted ads be shown.

3、添加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 >

4、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:

< ?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.eoeandroid.demo.Adadmob"

android:orientation="vertical"

Tags:AdMob android 应用

编辑录入:coldstar [复制链接] [打 印]
赞助商链接