简体   繁体   English

在棒棒糖5.1设备中未显示Admob

[英]Admob not show in lollipop 5.1 device

hello friends i wnat ot integrate admob in my application so i set following code for that 你好,我拥有的朋友将admob集成到我的应用程序中,因此我为此设置了以下代码

Main.java Main.java

public class Main extends Activity{

 AdView adView;
 RelativeLayout mRelativeLayoutRoot;
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.advs);
    mRelativeLayoutRoot=(RelativeLayout)findViewById(R.id.root);


    adView = new AdView(this);
    adView.setAdSize(AdSize.BANNER);
    adView.setAdUnitId(getResources().getString(R.string.admob_unit_id));
    adView.setId(11);
    LayoutParams lp;
    lp = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); // You might want to tweak these to WRAP_CONTENT
    lp.addRule(mRelativeLayoutRoot.ALIGN_PARENT_BOTTOM);
    mRelativeLayoutRoot.addView(adView, lp);
    AdRequest adRequest = new AdRequest.Builder()
    .build();

    adView.loadAd(adRequest);

}

} }

Manifest.xml Manifest.xml

<?xml version="1.0" encoding="utf-8"?>

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
            <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <activity
        android:name=".Main"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
     <activity
        android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />

</application>

</manifest>

When i run above code advertisement show only Jellybean , kitkat mobile device in Lolliop device 5.1 it is not showing any idea how can i solve this problem ? 当我在上述代码广告中仅显示Lolliop设备5.1中的 Jellybeankitkat移动设备时,没有显示任何想法如何解决此问题?

EDIT 编辑

When i run this cod ein Micomax android one phone (Lollipop 5.1) it is not show advertise on that 当我运行此cod ein Micomax android一部手机(Lollipop 5.1)时,它不显示advertise

Suggest you start by creating your AdView in the XML layout for your Activity rather than in code. 建议您从活动的XML布局而不是代码中创建AdView开始。 It will help eliminate a few potential errors. 这将有助于消除一些潜在的错误。

Next, make sure that you have added the deviceIds for the 2 devices as test device ids. 接下来,确保已添加2个设备的deviceId作为测试设备ID。

Finally, look at your logcat for the 2 devices and see what the Admob log says in the case when the ad does not load. 最后,查看两台设备的日志猫,看看Admob日志在未加载广告的情况下的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM