热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

使用Admob在android中实现本地广告?是可能的吗?-ImplementingnativeadsinandroidusingAdmob?isitpossible?

Imtryingtoimplementnativeadsinmyandroidapplication.ButIwanttodoitusingadmobonly.

I'm trying to implement native ads in my android application. But I want to do it using admob only. I searched a lot for solution but could not find exact one to do so.

我试图在我的android应用程序中实现本地广告。但是我想用admob来做。我搜索了很多,但找不到确切的答案。

I know it is possible using MoPub.

我知道使用MoPub是可能的。

What I wanted to do is this: Show ads inside list item which means one of the ListView/RecyclerView item can be one ad like below image. Image

我想做的是:在列表项中显示广告,这意味着列表视图/回收视图项可以是如下图所示的一个广告。

I found some links and references but that doesn't explain proper implementation of the native ads.

我找到了一些链接和引用,但这并不能解释本地广告的正确实现。

Link 1 : Native ads overview

链接1:本地广告概述

Link 2 : DFP Android Guides > Targeting

链接2:DFP Android指南>定位

Link 3 : DFP Quick Start Guide

链接3:DFP快速启动指南

If it is not possible to do it using admob, MoPub is best solution for me right now.

如果不能使用admob, MoPub是我目前最好的解决方案。

Any help and guidance would be helpful. thanks.

任何帮助和指导都是有益的。谢谢。

9 个解决方案

#1


2  

As an addition to this thread, you can now implement NativeAds for Admob very easily by following the guide provided by Google using NativeExpressAdView . For more information, check the google documentation : https://firebase.google.com/docs/admob/android/native-express?hl=en

作为这个线程的附加部分,您现在可以很容易地通过使用NativeExpressAdView的谷歌提供的向导实现Admob的NativeAds。要了解更多信息,请查看谷歌文档:https://firebase.google.com/docs/admob/android/native-express?

#2


5  

Try using some other ad networking where it provides different types of native ads. Developers can customize the ads where to place and use it. For eg: if you need to place ads at second cell every 15 row, you can use like this.

尝试使用其他的广告网络提供不同类型的原生广告。开发者可以定制广告的位置并使用它。例如:如果你需要每隔15行在第二个单元格放置广告,你可以这样使用。

Avocarrot provides that.

Avocarrot提供。

 AvocarrotInstream myAd = new AvocarrotInstream();
  myAd.initWithKey( "" );
  myAd.setSandbox(true);
  myAd.setLogger(true ,"ALL"); 

// Populate with In-Stream ads
 myAd.loadAdForPlacement(this,  "" );
// Bind the adapter to your list view component
.setAdapter(myAd);// here you are integrating ads to listview
 myAd.setFrequency(2,15); // every 15 cells starting from the 2nd cell. 

Here is Documentation it provides List ads and Feed ads.

这里是文档,它提供列表广告和提要广告。

#3


5  

Recently I stucked with the same question. Then I decided to post my solution for that to admobadapter. Hope it will help you.

最近我也遇到了同样的问题。然后我决定将我的解决方案发布到admobadapter。希望它能对你有所帮助。

The basic usage could look like:

基本用法如下:

    ListView lvMessages;
    AdmobAdapterWrapper adapterWrapper;    

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initListViewItems();
    }

    /**
     * Inits an adapter with items, wrapping your adapter with a {@link AdmobAdapterWrapper} and setting the listview to this wrapper
     * FIRST OF ALL Please notice that the following code will work on a real devices but emulator!
     */
    private void initListViewItems() {
        lvMessages = (ListView) findViewById(R.id.lvMessages);

        //creating your adapter, it could be a custom adapter as well
        ArrayAdapter adapter  = new ArrayAdapter(this,
                android.R.layout.simple_list_item_1);

        adapterWrapper = new AdmobAdapterWrapper(this);
        adapterWrapper.setAdapter(adapter); //wrapping your adapter with a AdmobAdapterWrapper.
        //here you can use the following string to set your custom layouts for a different types of native ads
        //adapterWrapper.setInstallAdsLayoutId(R.layout.your_installad_layout);
        //adapterWrapper.setcontentAdsLayoutId(R.layout.your_installad_layout);

        //Sets the max count of ad blocks per dataset, by default it equals to 3 (according to the Admob's policies and rules)
        adapterWrapper.setLimitOfAds(3);

        //Sets the number of your data items between ad blocks, by default it equals to 10.
        //You should set it according to the Admob's policies and rules which says not to
        //display more than one ad block at the visible part of the screen,
        // so you should choose this parameter carefully and according to your item's height and screen resolution of a target devices
        adapterWrapper.setNoOfDataBetweenAds(10);

        //It's a test admob ID. Please replace it with a real one only when you will be ready to deploy your product to the Release!
        //Otherwise your Admob account could be banned
        //String admobUnitId = getResources().getString(R.string.banner_admob_unit_id);
        //adapterWrapper.setAdmobReleaseUnitId(admobUnitId);

        lvMessages.setAdapter(adapterWrapper); // setting an AdmobAdapterWrapper to a ListView

        //preparing the collection of data
        final String sItem = "item #";
        ArrayList lst = new ArrayList(100);
        for(int i=1;i<=100;i++)
            lst.add(sItem.concat(Integer.toString(i)));

        //adding a collection of data to your adapter and rising the data set changed event
        adapter.addAll(lst);
        adapter.notifyDataSetChanged();
    }

And the result will look like the following

结果如下所示。

enter image description here

#4


4  

Native ads are included in Google Play Services along with the rest of DFP/AdMob advertising. Make sure you have the following listed as dependencies in your build.gradle (note that 7.5.0 is the highest version as of this posting).

本地广告包括在谷歌播放服务和其他的DFP/AdMob广告。确保您在构建中列出了以下依赖项。等级(请注意7.5.0是这篇文章的最高版本)。

compile "com.google.android.gms:play-services-base:7.5.0"
compile "com.google.android.gms:play-services-ads:7.5.0"

Then you can display native ads

然后你可以显示原生广告。

AdLoader adLoader = new AdLoader.Builder(context, "/6499/example/native")
    .forAppInstallAd(new OnAppInstallAdLoadedListener() {
        @Override
        public void onAppInstallAdLoaded(NativeAppInstallAd appInstallAd) {
            // Show the app install ad.
        }
    })
    .forContentAd(new OnContentAdLoadedListener() {
        @Override
        public void onContentAdLoaded(NativeContentAd contentAd) {
            // Show the content ad.
        }
    })
    .withAdListener(new AdListener() {
        @Override
        public void onAdFailedToLoad(int errorCode) {
            // Handle the failure by logging, altering the UI, etc.
        }
    })
    .withNativeAdOptions(new NativeAdOptions.Builder()
            // Methods in the NativeAdOptions.Builder class can be
            // used here to specify individual options settings.
            .build())
    .build();

Click here for complete documentation.

点击这里获得完整的文档。

#5


2  

Adding to the mix, Tooleap Ads SDK provides a simple way to implement Admob's native ads.

此外,Tooleap Ads SDK提供了一种实现Admob本地广告的简单方法。

Instead of requiring you to use the traditional listView adapter and showing the ad inside you content, they are showing admob native ads as a small floating bubble. When pressing on it you can see the full native ad.

他们没有要求您使用传统的listView适配器并在您的内容中显示广告,而是将admob本机广告显示为一个浮动的小气泡。按下它,你可以看到完整的本地广告。

Here is an example of using their SDK inside your activity class:

下面是在activity类中使用它们的SDK的一个例子:

BubbleImageAd = new BubbleImageAd(this);
bubbleImageAd.setAdUnitId("YOUR_AD_UNIT_ID");
bubbleImageAd.loadAndShowAd(this);

You can check them out here.

你可以在这里看看。

enter image description hereenter image description here

#6


1  

Well, this thread is probably outdated. But starting May 2015, and as of now, AdMob does support native ads (still in beta though).

这个线程可能已经过时了。但是从2015年5月开始,到现在为止,AdMob确实支持本地广告(尽管仍在测试中)。

https://support.google.com/admob/answer/6239795

https://support.google.com/admob/answer/6239795

Also it's available only to a limited number of developers as of its beta stage.

此外,在beta阶段,只有有限数量的开发人员可以使用它。

#7


1  

Add this code to your Listview Adapter

将此代码添加到您的Listview适配器

       builder.forAppInstallAd(new NativeAppInstallAd.OnAppInstallAdLoadedListener() {
            @Override
            public void onAppInstallAdLoaded(NativeAppInstallAd ad) {
                FrameLayout frameLayout =
                        (FrameLayout) findViewById(R.id.fl_adplaceholder);
                NativeAppInstallAdView adView = (NativeAppInstallAdView) getLayoutInflater()
                        .inflate(R.layout.ad_app_install, null);
                populateAppInstallAdView(ad, adView);
                frameLayout.removeAllViews();
                frameLayout.addView(adView);
            }
        });

       AdLoader adLoader = builder.withAdListener(new AdListener() {
        @Override
        public void onAdFailedToLoad(int errorCode) {
            Toast.makeText(MainActivity.this, "Failed to load native ad: "
                    + errorCode, Toast.LENGTH_SHORT).show();
        }
      }).build();

        adLoader.loadAd(new AdRequest.Builder().build());

Make some changes for listview Adapter and you will get populateAppInstallAdView() method from below link

对listview适配器做一些更改,您将从下面的链接中获得populateAppInstallAdView()方法

Everything is covered in this example please go through this https://github.com/googleads/googleads-mobile-android-examples/tree/master/admob

本例中包含了所有内容,请通过这个https://github.com/googleads/googleadss-mobile -android-examples/tree/master/admob

#8


1  

Admob in your android these are the codes needed. 
    

//In your java class file

//在java类文件中

     AdView mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);

#9


0  

It is restricted to selected publishers at the moment. You'll need to contact a Google account manager in your region for implementation.

目前它仅限于选定的出版商。您需要联系您所在地区的谷歌帐户管理器进行实现。


推荐阅读
  • 本文详细介绍了MySQL表分区的创建、增加和删除方法,包括查看分区数据量和全库数据量的方法。欢迎大家阅读并给予点评。 ... [详细]
  • Google Play推出全新的应用内评价API,帮助开发者获取更多优质用户反馈。用户每天在Google Play上发表数百万条评论,这有助于开发者了解用户喜好和改进需求。开发者可以选择在适当的时间请求用户撰写评论,以获得全面而有用的反馈。全新应用内评价功能让用户无需返回应用详情页面即可发表评论,提升用户体验。 ... [详细]
  • 本文介绍了关于Java异常的八大常见问题,包括异常管理的最佳做法、在try块中定义的变量不能用于catch或finally的原因以及为什么Double.parseDouble(null)和Integer.parseInt(null)会抛出不同的异常。同时指出这些问题是由于不同的开发人员开发所导致的,不值得过多思考。 ... [详细]
  • 如何自行分析定位SAP BSP错误
    The“BSPtag”Imentionedintheblogtitlemeansforexamplethetagchtmlb:configCelleratorbelowwhichi ... [详细]
  • IhaveconfiguredanactionforaremotenotificationwhenitarrivestomyiOsapp.Iwanttwodiff ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • 20211101CleverTap参与度和分析工具功能平台学习/实践
    1.应用场景主要用于学习CleverTap的使用,该平台主要用于客户保留与参与平台.为客户提供价值.这里接触到的原因,是目前公司用到该平台的服务~2.学习操作 ... [详细]
  • 解决VS写C#项目导入MySQL数据源报错“You have a usable connection already”问题的正确方法
    本文介绍了在VS写C#项目导入MySQL数据源时出现报错“You have a usable connection already”的问题,并给出了正确的解决方法。详细描述了问题的出现情况和报错信息,并提供了解决该问题的步骤和注意事项。 ... [详细]
  • 拥抱Android Design Support Library新变化(导航视图、悬浮ActionBar)
    转载请注明明桑AndroidAndroid5.0Loollipop作为Android最重要的版本之一,为我们带来了全新的界面风格和设计语言。看起来很受欢迎࿰ ... [详细]
  • 本文详细介绍了Java中vector的使用方法和相关知识,包括vector类的功能、构造方法和使用注意事项。通过使用vector类,可以方便地实现动态数组的功能,并且可以随意插入不同类型的对象,进行查找、插入和删除操作。这篇文章对于需要频繁进行查找、插入和删除操作的情况下,使用vector类是一个很好的选择。 ... [详细]
  • 在Xamarin XAML语言中如何在页面级别构建ControlTemplate控件模板
    本文介绍了在Xamarin XAML语言中如何在页面级别构建ControlTemplate控件模板的方法和步骤,包括将ResourceDictionary添加到页面中以及在ResourceDictionary中实现模板的构建。通过本文的阅读,读者可以了解到在Xamarin XAML语言中构建控件模板的具体操作步骤和语法形式。 ... [详细]
  • 本文介绍了腾讯最近开源的BERT推理模型TurboTransformers,该模型在推理速度上比PyTorch快1~4倍。TurboTransformers采用了分层设计的思想,通过简化问题和加速开发,实现了快速推理能力。同时,文章还探讨了PyTorch在中间层延迟和深度神经网络中存在的问题,并提出了合并计算的解决方案。 ... [详细]
  • 本文介绍了响应式页面的概念和实现方式,包括针对不同终端制作特定页面和制作一个页面适应不同终端的显示。分析了两种实现方式的优缺点,提出了选择方案的建议。同时,对于响应式页面的需求和背景进行了讨论,解释了为什么需要响应式页面。 ... [详细]
  • macOS Big Sur全新设计大版本更新,10+个值得关注的新功能
    本文介绍了Apple发布的新一代操作系统macOS Big Sur,该系统采用全新的界面设计,包括图标、应用界面、程序坞和菜单栏等方面的变化。新系统还增加了通知中心、桌面小组件、强化的Safari浏览器以及隐私保护等多项功能。文章指出,macOS Big Sur的设计与iPadOS越来越接近,结合了去年iPadOS对鼠标的完善等功能。 ... [详细]
  • 本文介绍了Python语言程序设计中文件和数据格式化的操作,包括使用np.savetext保存文本文件,对文本文件和二进制文件进行统一的操作步骤,以及使用Numpy模块进行数据可视化编程的指南。同时还提供了一些关于Python的测试题。 ... [详细]
author-avatar
Wei-Micro_788
这个家伙很懒,什么也没留下!
Tags | 热门标签
RankList | 热门文章
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有