Android 是否有任何 AdMob 虚拟 ID?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12553929/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 10:57:28  来源:igfitidea点击:

Is there any AdMob dummy id?

androidadmob

提问by Rushikesh Talokar

Is there any AdMob dummy ids for testing purpose? Do I need to register app & get MY_AD_UNIT_ID?

是否有任何用于测试目的的 AdMob 虚拟 ID?我需要注册应用程序并获取 MY_AD_UNIT_ID 吗?

采纳答案by Siddharth Lele

There aren't dummy ID's per se. You need to setup the XML or the JAVA code to get test ads. To get Test Adsduring testing, add the following to your XML where you have the AdViewdeclared.

本身没有虚拟 ID。您需要设置 XML 或 JAVA 代码才能获取测试广告。要在测试期间获取测试广告,请将以下内容添加到您AdView声明的XML 中。

NOTE: I use just the XML code to display Ads in my app.

注意:我只使用 XML 代码在我的应用中显示广告。

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="bottom|center"
    android:orientation="horizontal" >

    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="YOUR_AD_UNIT_ID"
        ads:loadAdOnCreate="true"
        ads:testDevices="TEST_EMULATOR, YOUR_DEVICE_ID" >
    </com.google.ads.AdView>
</LinearLayout>

To set the Test Unit (Both the emulator and your devices) from JAVA:

从 JAVA 设置测试单元(模拟器和您的设备):

AdRequest adRequest = new AdRequest();
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);            
adRequest.addTestDevice("test");

To get your Device ID, you can use this:

要获取您的设备 ID,您可以使用:

final TelephonyManager tm = (TelephonyManager)getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
String deviceid = tm.getDeviceId();

From: https://stackoverflow.com/a/9681517/450534

来自:https: //stackoverflow.com/a/9681517/450534

EDIT: Missed your second question.

编辑:错过了你的第二个问题。

Yes. You will need to register your app in your Ad-Mob account. Without that being registered, you won't be getting your Ad Unit ID and therefore, no Ads in your app either.

是的。您需要在 Ad-Mob 帐户中注册您的应用。如果没有注册,您将无法获得您的广告单元 ID,因此您的应用中也没有广告。

UPDATE:Approximately two years after posting this answer, Google added a few dummy ID's to their admob SDK. Please refer to the other better voted answers for the dummy ID's

更新:发布此答案大约两年后,Google 在他们的 admob SDK 中添加了一些虚拟 ID。请参阅虚拟 ID 的其他更好的投票答案

回答by penduDev

This is the dummy id for Banner ads.

这是横幅广告虚拟 ID

ca-app-pub-3940256099942544/6300978111

ca-app-pub-3940256099942544/6300978111

source

来源

回答by Mariusz Jamro

Banner:

横幅:

ca-app-pub-3940256099942544/6300978111

Interstitial:

插页式:

ca-app-pub-3940256099942544/1033173712

Rewarded Video:

奖励视频:

ca-app-pub-3940256099942544/5224354917

Native Advanced:

原生高级:

ca-app-pub-3940256099942544/2247696110

Native Advanced Video:

原生高级视频:

ca-app-pub-3940256099942544/1044960115

Native Express Small/Large:

Native Express 小/大:

ca-app-pub-3940256099942544/2793859312 
ca-app-pub-3940256099942544/2177258514

source

来源

回答by Dinesh Sunny

OS: Android

操作系统:安卓

Mediation: Admob

调解:Admob

For Banner Ads:

对于横幅广告:

ca-app-pub-3940256099942544/6300978111

Source

来源

For Interstitial Ads:

对于插页式广告:

ca-app-pub-3940256099942544/1033173712

Source

来源

For Admob NativeExpress Ads:

对于 Admob NativeExpress 广告:

ca-app-pub-3940256099942544/1072772517

For Rewarded Video

对于奖励视频

ca-app-pub-3940256099942544/5224354917

Note:

笔记:

The NativeExpressAd you'll see looks like a real one, but it's counted as a test ad. You're free to use that ad unit ID for your testing.

您将看到的 NativeExpressAd 看起来像一个真实的广告,但它被视为测试广告。您可以随意使用该广告单元 ID 进行测试。

by Andrew Brogdon(Google Ads Team in one of his youtube comments)

作者:Andrew Brogdon(Google Ads 团队在他的 youtube 评论之一中)

enter image description here

在此处输入图片说明

All test Ads you can find in the actual admob github repositoryin the res > values > strings.xml

您可以在 res > values > strings.xml的实际admob github 存储库中找到的所有测试广告

回答by Rahel

Here is an official update from google

这是谷歌的官方更新

Android

安卓

  • Banner: ca-app-pub-3940256099942544/6300978111
  • Interstitial : ca-app-pub-3940256099942544/1033173712
  • Reward Video: ca-app-pub-3940256099942544/5224354917
  • Native Advanced: ca-app-pub-3940256099942544/2247696110
  • Native Express (small): ca-app-pub-3940256099942544/2793859312
  • Native Express (large): ca-app-pub-3940256099942544/2177258514
  • 横幅: ca-app-pub-3940256099942544/6300978111
  • 插页式: ca-app-pub-3940256099942544/1033173712
  • 奖励视频: ca-app-pub-3940256099942544/5224354917
  • 原生高级: ca-app-pub-3940256099942544/2247696110
  • Native Express(小): ca-app-pub-3940256099942544/2793859312
  • Native Express(大): ca-app-pub-3940256099942544/2177258514

IOS

IOS

  • Banner:ca-app-pub-3940256099942544/6300978111

  • Interstitial ca-app-pub-3940256099942544/1033173712

  • Rewarded Video ca-app-pub-3940256099942544/1712485313

  • Native Advanced ca-app-pub-3940256099942544/2247696110

  • Native Express (Small): ca-app-pub-3940256099942544/4270592515

  • Native Express(Large): ca-app-pub-3940256099942544/8897359316

  • 横幅:ca-app-pub-3940256099942544/6300978111

  • 插页式 ca-app-pub-3940256099942544/1033173712

  • 奖励视频 ca-app-pub-3940256099942544/1712485313

  • 原生高级 ca-app-pub-3940256099942544/2247696110

  • Native Express(小): ca-app-pub-3940256099942544/4270592515

  • 原生快递(大): ca-app-pub-3940256099942544/8897359316

Read more:

阅读更多:

回答by AMAN SINGH

For RewardedVideoyou can use the following one :

因为RewardedVideo您可以使用以下一个:

private static final String AD_UNIT_ID = "ca-app-pub-3940256099942544/5224354917";
private static final String APP_ID = "ca-app-pub-3940256099942544~3347511713";

how to use:

如何使用:

MobileAds.initialize(this, APP_ID);

mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
mRewardedVideoAd.setRewardedVideoAdListener(this);
mRewardedVideoAd.loadAd(AD_UNIT_ID, new AdRequest.Builder().build());

for showing

用于展示

 if (mRewardedVideoAd.isLoaded()) {
        mRewardedVideoAd.show();
  }

Hope this will help many of us!

希望这会帮助我们很多人!

回答by PrakashSharma

Sample adMob by google

谷歌的示例 adMob

<com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    ads:adSize="BANNER"
    ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>

回答by S__

And sample app id for tests : ca-app-pub-3940256099942544~3347511713

以及用于测试的示例应用程序 ID:ca-app-pub-3940256099942544~3347511713