Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8532717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:46:44+00:00 2026-06-11T09:46:44+00:00

The following code is what I implemented just to check admob ads retrieval but

  • 0

The following code is what I implemented just to check admob ads retrieval but I couldn’t get any ads although the code is even no crashing.
Please inform what is wrong in this code.

public class MainActivity extends Activity {

    public AdView  admobView;
    public View mainView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        admobView = new AdView(this, AdSize.BANNER, "Top secret");
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT,
                RelativeLayout.LayoutParams.WRAP_CONTENT);
        lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        admobView.setLayoutParams(lp);
        //mainView.setLayoutParams(lp);

        RelativeLayout layout = new RelativeLayout(this);

        AdRequest adRequest = new AdRequest();

        //tested this
        adRequest.addTestDevice(AdRequest.TEST_EMULATOR);               // Emulator

        //tested this
        //adRequest.addTestDevice("20cb18e8ffc74ad2");

        //tested this
        //adRequest.addMediationExtra("3d879f364d5747c5", null);
        admobView.loadAd(adRequest);
        layout.addView(admobView);
        //layout.addView(mainView);

        setContentView(layout);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:46:45+00:00Added an answer on June 11, 2026 at 9:46 am

    Did you add permissions and congifchanges of admob in your menifest. Cause i have run your code and it displayed in my emulator. And also in order to display add your app’s targetSdkVersion need to be greater then 14.

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    
    <activity android:name="com.google.ads.AdActivity"
                android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" >
            </activity>
    

    Activity is as like you

    public AdView  admobView;
        public View mainView;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            admobView = new AdView(this, AdSize.BANNER, "a14f39f0b52dce6");
            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                    RelativeLayout.LayoutParams.WRAP_CONTENT,
                    RelativeLayout.LayoutParams.WRAP_CONTENT);
            lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            admobView.setLayoutParams(lp);
            //mainView.setLayoutParams(lp);
    
            RelativeLayout layout = new RelativeLayout(this);
    
            AdRequest adRequest = new AdRequest();
    
            //tested this
            adRequest.addTestDevice(AdRequest.TEST_EMULATOR);               // Emulator
    
            //tested this
            //adRequest.addTestDevice("20cb18e8ffc74ad2");
    
            //tested this
            //adRequest.addMediationExtra("3d879f364d5747c5", null);
            admobView.loadAd(adRequest);
            layout.addView(admobView);
            //layout.addView(mainView);
    
            setContentView(layout);
        }
    

    And Manifest is ==

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.ee"
        android:versionCode="1"
        android:versionName="1.0" >
    
        <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="15" />
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
        <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name=".MainActivity"
                android:label="@string/title_activity_main" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <activity android:name="com.google.ads.AdActivity"
                android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" >
            </activity>
        </application>
    
    </manifest>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've implemented the following code on the site I'm working on which works great,
I've have already implemented pagination using the following code: public Paginacao<Anuncio> consultarPaginado(int pagina, Integer
I've implemented url routing under asp.net 3.5 with the following code: public IHttpHandler GetHttpHandler(RequestContext
We implemented In-app Billing one year ago with no problems following the sample code
I'm trying to implement autocomplete for a textbox using the following code, but it's
The purpose of the following code is to implement a LIFO container just like
I get a NullPointerException at a line on which just a simple null check
I have implemented the following code in my CPTScatterPlotDelegate to display a callout bubble:
I use the following code to refresh an image in the browser. I just
Following code worked fine abstract class FunctionRunnable<V> implements Runnable { protected abstract V calculate();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.