AdMob广告在模拟器,但不是在真实设备展示 [英] Admob ads showing in emulator but not in real device

查看:629
本文介绍了AdMob广告在模拟器,但不是在真实设备展示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经集成AdMob广告在我的应用程序,但在广告仿真器出现了,但是当我在实际设备尝试它没有显示出来。对于集成我已经在下面加code在AndroidManifest.xml

I have integrated admob in my app but the ads showed up in emulator but when i tried in real device it's not showing up. For integration i have added below code in AndroidManifest.xml

<!-- Internet Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Network State Permissions -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Google Play service -->
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
<!-- Ad activity -->
    <activity
        android:name="com.google.android.gms.ads.AdActivity"   android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />

然后在我的活动的布局我已经添加下面的LinearLayout加载广告的吧:

Then in my activity's layout i have added below Linearlayout to load the ad in it :

<LinearLayout
    android:id="@+id/main_menu_banner"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:gravity="center"
    android:orientation="horizontal" />

然后在活动我已经写了下面的Java code集成:

Then in activity i have written below java code for integration :

/* The view to show the ad. */
private AdView adView;
/* Your ad unit id. Replace with your actual ad unit id. */
private static final String AD_UNIT_ID = "My_admob_key";
// Create an ad.
adView = new AdView(MainMenu.this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(AD_UNIT_ID);
// Add the AdView to the view hierarchy. The view will have no size
// until the ad is loaded.
LinearLayout layout = (LinearLayout) findViewById(R.id.main_menu_banner);
layout.addView(adView);
// Initiate a generic request.
AdRequest adRequest = new AdRequest.Builder().build();
// Load the adView with the ad request.
adView.loadAd(adRequest);
layout.bringToFront();

任何帮助将是AP preciated为什么广告显示不出来!!!!你还可以指向任何好的政党成员整合AdMob还会帮助。在此先感谢

Any help would be appreciated why ads are not showing up!!!! Also you can point to any good tuto for integrating admob will also help. Thanks in advance

推荐答案

添加额外以及

 AdMobExtras extras = new AdMobExtras(bundle);
 AdRequest adRequest = new AdRequest.Builder()
 .addNetworkExtras(extras).build();
 adView.loadAd(adRequest);

这篇关于AdMob广告在模拟器,但不是在真实设备展示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆