zoukankan      html  css  js  c++  java
  • 为免费app嵌入Admob广告

    为免费app嵌入Admob广告,进而获得广告收入。

    1.http://www.admob.com/注册一个帐号,

    添加Add Mobile Site/app,输入相关信息后,提交完成,

    下载Android平台使用的JAR,查看发布者 ID。

    2.然后将JAR添加到你的项目中

    Properties->Java Build Path->Libraries->Add JARs…->Select the JAR->OK

    3.编辑AndroidManifest.xml

    application节点中添加

    <!– The application’s publisher ID assigned by AdMob –>

    <meta-data android:value=”a14ae1ce0357305″ android:name=”ADMOB_PUBLISHER_ID” />

    manifest节点添加权限申请

    <!– AdMob SDK permissions –>

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

    4.添加attrs.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.添加广告组件

    <?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嵌入Admob广告,进而获得广告收入。

    adm

  • 相关阅读:
    冒泡排序
    linux常用命令
    Github上将公共仓库转为私有仓库or私有仓库转为共有仓库
    使用apt更新和升级系统软件
    Django用户认证模块中继承AbstractUser与AbstractBaseUser重写User表的区别
    详解django中的collectstatic命令以及STATIC_URL、STATIC_ROOT配置
    python入门指南
    python包装不上?国内网络问题,使用豆瓣源解决
    nginx入门
    Vue 实现页面刷新(provide 和 inject)
  • 原文地址:https://www.cnblogs.com/android-blogs/p/5007084.html
Copyright © 2011-2022 走看看