Android studio 添加admob googgle play services
Android studio 添加admob googgle play services
MainActivity
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.MobileAds;
private InterstitialAd mInterstitialAd;
// Initialize the Mobile Ads SDK.
MobileAds.initialize(getApplicationContext(), "ca-app-pub-8067415904846806/59920985");
// Create the InterstitialAd and set the adUnitId.
mInterstitialAd = new InterstitialAd(this);
// Defined in res/values/strings.xml
mInterstitialAd.setAdUnitId("xxx"); mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
// startGame();
}
@Override
public void onAdLoaded() {
super.onAdLoaded();
Log.i("sdf","Ad loaded !");
}
});
AdRequest adRequest = new AdRequest.Builder().addTestDevice("0E1F15F35CE93F7A77BDDB59F7FE29AF").build();
mInterstitialAd.loadAd(adRequest); AndroidManifest.xml
<!-- Used to request banner and interstitial ads. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Used to avoid sending an ad request if there is no connectivity. -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Required permissions for video ads. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" /> <activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" /> app build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
compile 'com.google.android.gms:play-services-ads:10.2.0'
compile 'com.android.support:multidex:1.0.1'
}
apply plugin: 'com.google.gms.google-services'
project build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.4.0-alpha6'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Android studio 添加admob googgle play services的更多相关文章
- 在Xcode5和Android Studio添加工程间的依赖
正在编辑中,尚未完成 先看看ios的target是什么,请先参看http://www.cocoachina.com/bbs/read.php?tid-10884.html做个大概了解 这里有一篇文章, ...
- Eclipse / android studio 添加第三方jar包 步骤
eclipse 将第三方包放到libs文件夹后并没有引用. 基本步骤分为3步,具体介绍如下: 打开自己的Eclipse,在自己的Android工程上名上右键->Build Path ->C ...
- Android Studio 添加Assets目录
Android Studio 添加Assets目录: 法一: Since Android Studio uses the new Gradle-based build system, you shou ...
- 【Android Studio安装部署系列】十五、Android studio添加Assets目录
版权声明:本文为HaiyuKing原创文章,转载请注明出处! 概述 Android Studio新建项目时是没有assets目录,需要自己手动创建. app右键——New——Folder——Asset ...
- 在Android Studio添加本地aar包引用
1.如何在Android Studio添加本地aar包引用 https://jingyan.baidu.com/article/2a13832890d08f074a134ff0.html 2.完成上述 ...
- android studio 添加get,set方法快捷方式
android studio 添加get,set方法快捷方式
- Android Studio 添加 Genymotion插件
原文:Android Studio 添加 Genymotion插件 1.下载Genymotion:官网地址,必须先注册才能下载,下载带有VirtualBox的版本 2.安装:安装时会连VirtualB ...
- Android Studio(六):Android Studio添加注释模板
Android Studio相关博客: Android Studio(一):介绍.安装.配置 Android Studio(二):快捷键设置.插件安装 Android Studio(三):设置Andr ...
- 2.5、Android Studio添加多适配的向量图片
Android Studio包含一个Vector Asset Studio的工具,可以帮助你添加Material图标和导入SVG(Scalable Vector Graphic)文件到你的项目中作为向 ...
随机推荐
- error: command 'gcc' failed with exit status 1 while installing eventlet
Ubuntu安装Python包出错解决办法 : sudo apt-get install python-dev sudo apt-get install libevent-dev
- Oracle Unicode转中文(解码)
Oracle Unicode转中文(解码) CreateTime--2018年3月29日15:23:30 Author:Marydon 情景描述: 将数据库中的某个字段误存储的是Unicode编码 ...
- 〖Linux〗ltib的使用帮助
scue@Link:/home/work/ltib$ ./ltib --help This script is used to manage the building of BSPs with com ...
- 重新安装Drupal?
因个人需要需要重新安装Drupal.如何操纵呢?Drupal是在_drupal_bootstrap_database()函数里面检查是否已经安装过的.检查的依据是有没有$GLOBALS['databa ...
- window.onunload | window.onbeforeunload
先引述一段jQuery 官方对于onunload的评述: The unload event is sent to the window element when the user navigates ...
- cocos2dx 关于lua 绑定的环境配置官方文档翻译与 将自己定义c++方法绑定到lua的的方法
网上有好多写如何讲自己定义的方法绑定到lua的文章,当中都仅仅对环境配置做了简单的介绍,看到有的帖子写在绑定中遇到了各种各样的error.大部分是因为环境配置不对导致的,下面是官方的文档有标准的说明, ...
- 阿里云 部署并开启nodejs应用
1.下载资源 $ wget https://nodejs.org/dist/v8.11.2/node-v8.11.2-linux-x64.tar.xz 2.xz解压 $ xz -d node-v8. ...
- cocos2dx 3.3 异步加载纹理
这里以3d场景加载为例,2d情况类似. 先同步加载模型数据和尺寸缩小了100倍的贴图,创建mesh.然后异步加载所有精细纹理并每加载完一个就替换一个,并进入场景. 如此做法的效果是当刚进入场景时看到的 ...
- Object-C中的类-类的声明
1.关键字命名:为了避免与已有的c,C++关键字冲突,ObjectC关键字都有@开始: 如:@classs,@interface,@private,@try,@catch,@protocol等. 2 ...
- 如何查看Linux操作系统的位数
如何查看Linux操作系统的位数 1.编程实现: 在程序中返回sizeof(int)的值,返回的结果是操作系统的字节数.若返回4则是32位操作系统,返回8即是64位. 2.2.getconf命令: g ...