

App变现之Admob原生广告,admob广告变现App变现之Admob原生广告Admob介绍admob是Google的移动广告平台,集成admob的SDK到APP中,获取广告数据展示出来,可以给我们带来广告收益。对于大流量的应用,如果可以在合适的位置,无缝的加入广告,可以带来可观的广告收入,这已经是一个公开的成功商业......
Admob介绍
admob是Google的移动广告平台,集成admob的SDK到APP中,获取广告数据展示出来,可以给我们带来广告收益。对于大流量的应用,如果可以在合适的位置,无缝的加入广告,可以带来可观的广告收入,这已经是一个公开的成功商业模式。有心的小伙伴可以往这个方向尝试,财务自由指日可待哦!
先上张admob原生广告的效果图,这是一张内容类型的原生广告。
Admob广告类型
Admob有哪几种展现形式的广告呢?
Banner(横幅广告):最常见的,就是平时看到的屏幕的底部或者顶部有一个横条的广告条。
Interstitial(插页广告):类似启动页广告,整个屏幕显示一副广告。
Rewarded Video(应用内购买广告):这个玩国外游戏经常会看到,你看完一个广告视频,游戏会奖励你一些道具或者其他的什么(这个奖励是一个整数,在AdMob中可以设置数量,用户看完视频会得到这个数量的奖励,比如奖励3瓶药水,3条生命等)。
Native(原生广告):这个是体验最好的广告形式,和原生app无缝对接,也许你已经见过一个列表的某个item内容展示的是广告,就是这种形式。
Admob广告接入入门
下面就以Admob的原生广告为例,带大家入门一下,怎么集成使用。
预备条件
Target Android API level 14 or higher
Admob官网注册添加应用和广告单元
添加依赖
dependencies{
implementationcom.google.android.gms:playservicesads:17.0.0
}
配置AndroidManifest.xml
lt;manifestgt;
lt;applicationgt;
lt;!Sample AdMob App ID:caapppub3940256099942544~3347511713gt;
lt;metadata
android:name=com.google.android.gms.ads.APPLICATION_ID
android:value=[ADMOB_APP_ID]/gt;
lt;/applicationgt;
lt;/manifestgt;
注意:对于Google Mobile Ads SDK version 17.0.0,这一步是必须的
初始化SDK
在广告加载之前,需要向MobileAds传入app id初始化SDK,这里要注意,需要在admob上注册应用后才有app id哦。
下面代码是在Activity中初始化的,最理想的时机是在应用启动的时候。
package...
import...
import com.google.android.gms.ads.MobileAds;
public class MainActivity extends AppCompatActivity{
...
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Sample AdMob app ID:caapppub3940256099942544~3347511713
MobileAds.initialize(this,YOUR_ADMOB_APP_ID);
}
...
}
加载广告
首先需要构建AdLoader,在Builder中传入广告单元id,不同广告位对应不同的广告单元。
AdLoader.Builder builder=new AdLoader.Builder(this,ADMOB_AD_UNIT_ID);
builder.forAppInstallAd(new NativeAppInstallAd.OnAppInstallAdLoadedListener(){
Override
public void onAppInstallAdLoaded(NativeAppInstallAd nativeAd){
FrameLayout frameLayout=
findViewById(R.id.fl_adplaceholder);
NativeAppInstallAdView adView=(NativeAppInstallAdView)getLayoutInflater()
.inflate(R.layout.ad_app_install,null);
populateUnifiedNativeAdView(nativeAd,adView);
frameLayout.removeAllViews();
rameLayout.addView(adView);
}
});
AdLoader adLoader=builder.withAdListener(new AdListener(){
Override
public void onAdFailedToLoad(int errorCode){
Toast.makeText(SingleAdActivity.this,Failed to load native ad:
+errorCode,Toast.LENGTH_SHORT).show();
}
}).build();
加载单条广告:
adLoader.loadAd(new AdRequest.Builder().build());
如果需要加载多条广告,admob也提供了加载多条广告的方法,如下:
adLoader.loadAds(new AdRequest.Builder().build(),3);
不过有一定限制,获取多条广告的上限为5,你可以传入参数5,但最多返回5条广告,也有可能小于5条。每收到一条广告,onAppInstallAdLoaded会回调一次。
如果获取多条广告,怎么知道数据加载完毕呢?可以通过isLoading()判断广告是否全部加载完毕:
final AdLoader adLoader=new AdLoader.Builder(this,caapppub3940256099942544/2247696110)
.forAppInstallAd(new NativeAppInstallAd.OnAppInstallAdLoadedListener(){
Override
public void onAppInstallAdLoaded(NativeAppInstallAd ad){
...
//some code that displays the app install ad.
...
if(adLoader.isLoading()){
//The AdLoader is still loading ads.
//Expect more adLoaded or onAdFailedToLoad callbacks.
}else{
//The AdLoader has finished loading ads.
}
}
}).build();
ad view class
从上面一路看下来,留心的小伙伴可能已经注意到了NativeAppInstallAdView这个类,从命名看,这个类应该是属于SDK里面的,是用来做什么的呢?
这个类确实来自SDK,先要从原生广告类型说起,Admob原生广告有两种类型,NativeAppInstallAd和NativeContentAd:
·NativeAppInstallAd是应用安装类型的广告,对应到View是NativeAppInstallAdView
·NativeContentAd是内容类型的广告,对应到View是NativeContentAdView
上面的两个View class,我们在使用时,必须把它们作为广告布局的父View,这是必须要遵守的使用规范。
如下是以NativeContentAdView作为父View的广告布局:
lt;com.google.android.gms.ads.formats.NativeContentAdView
xmlns:android=https://schemas.android.com/apk/res/android
android:layout_width=match_parent
android:layout_height=wrap_contentgt;
lt;LinearLayout
android:orientation=vertical
...gt;
lt;LinearLayout
android:orientation=horizontal
...gt;
lt;TextView
android:id= +id/contentad_headline
.../gt;
lt;/LinearLayoutgt;
//Other assets such as image or media view,call to action,etc follow.
...
lt;/LinearLayoutgt;
lt;/com.google.android.gms.ads.formats.NativeContentAdViewgt;
Admob原生广告官方demo
这里给两个官方放在github上的demo,大家可以参考看看:
googleads demo:https://github.com/googleads/googleadsmobileandroidexamples
googlecodelabs demo:https://github.com/googlecodelabs/admobnativeadvancedfeed
注意事项
·广告位添加后,可能需要等上2个小时才能使用
·不依赖gms,Admob广告在国内也可以使用,但是试了一下,不翻墙好像也加载不出来
他山之石
分享几个从别人文章看来的几条广告运营的经验:
1.首屏一定要展示广告。这主要是因为产品首屏的曝光量大,但广告要展示得当。
2.多账户分担风险。因为用一个账户创建所有的ad unit/placement时,虽然接入的工作量小,但风险过于集中了,哪天账户被封了就欲哭无泪了;因此建议同时创建3.多个广告账户,在产品里面轮流使用,很多时候违规也只是其中的一个,哪怕被封损失也小。
4.多平台互为备份。例如Facebook/Admob两个平台互为备份,当Facebook广告请求不到或加载不了时,则展示Admob广告,这样能最大化保证广告展现。
5.最大化广告刷新机制。例如用户刷新内容列表,哪怕内容没更新,把列表里面的广告重新请求并换一批。
6.广告预加载机制。不用等到用户请求时再去向广告平台发起请求,可以提前请求到数据,需要的时候随时可用,这样可以保证流畅体验。
选择合适的广告形式。毕竟有banner广告,插屏广告,原生广告等那么多样式,选择广告形式的时候最好能跟当前广告位结合起来。
参考资料
https://developers.google.com/admob/android/quickstart
https://developers.google.com/admob/android/native
https://firebase.google.com/docs/admob/
https://github.com/googleads/googleadsmobileandroidexamples
https://github.com/googlecodelabs/admobnativeadvancedfeed
https://www.jianshu.com/p/4dbe269500b8
特别声明:以上文章内容仅代表作者本人观点,不代表ESG跨境电商观点或立场。如有关于作品内容、版权或其它问题请于作品发表后的30日内与ESG跨境电商联系。
二维码加载中...
使用微信扫一扫登录
使用账号密码登录
平台顾问
微信扫一扫
马上联系在线顾问
小程序
ESG跨境小程序
手机入驻更便捷
返回顶部