简体   繁体   English

Android应用中的Admob Adview标语广告展示

[英]Admob Adview Banner Ad show in Android apps

In my Activity I have used this 在我的活动中,我使用了这个

public class MainActivity extends Activity {

AdView adView;

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

    adView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().addTestDevice(
            "BD9386F17F7DE795B86B5BBBEDDF1095").build();
    adView.loadAd(adRequest);
}

@Override
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    adView.pause();
}

@Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    adView.resume();
}

@Override
protected void onDestroy() {
    // TODO Auto-generated method stub
    super.onDestroy();
    adView.destroy();
}

} }

in my xml i used this 在我的xml中,我使用了这个

  <com.google.android.gms.ads.AdView
     xmlns:ads="http://schemas.android.com/apk/res-auto"
     android:id="@+id/adView"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentBottom="true"
     ads:adSize="SMART_BANNER"
     ads:adUnitId="ca-app-pub-5000769796423780/7961881354" />

And in My Manifest 在我的清单中

I have used this permission 我已经使用了此权限

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

And This metadata 而且这个元数据

<meta-data android:name="com.google.android.gms.version"
                android:value="@integer/google_play_services_version"/>

I have used this code all the time but this time it is not working. 我一直在使用此代码,但这次却无法正常工作。 Even there is no error in Logcat. 即使Logcat中没有错误。 Recently i used api-21. 最近,我使用了api-21。

Have you added the AdActivity to the manifest ? 您是否已将AdActivity添加到清单中

<activity 
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />

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

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