adding google ads to android app

孤者浪人 提交于 2019-12-03 16:42:59

I have used this jar file - GoogleAdMobAdsSdk-4.0.4.jar

have you imported this lines

import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;


        AdView adView = new AdView(this, AdSize.BANNER,
                    getString(R.string.publisherID));


        LinearLayout layout = (LinearLayout) findViewById(R.id.imgBanner);
        layout.addView(adView);

        AdRequest adRequest = new AdRequest();
        adRequest.setTesting(true);
        // Start loading the ad in the background.
        adView.loadAd(adRequest);

In XML I have just written this

<LinearLayout
    android:id="@+id/imgBanner"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true" />

ANd in Manifest file

<activity
    android:name="com.google.ads.AdActivity"
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode" >
</activity>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!