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 7864007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:39:37+00:00 2026-06-02T23:39:37+00:00

I am trying to implement admob in my app, but I can’t get it

  • 0

I am trying to implement admob in my app, but I can’t get it working.

I have a Class A, which is the main class, it extends activity.
I have a Class B, which is the class that is called when the application start. I have the following piece of code in class A to archive this:

B b = new B(this);
setContentView(B);

In class B I have a canvas with test and bitmaps. I want to put an ad on the canvas with admob, but I can’t archive this. Class B:

private AdView adView;
int[] degree = { 90, 180, 270, 360 };// random graden eindposities pijl
// int width, height;
Random rand = new Random();
Typeface font;
Matrix matrix = new Matrix();// degree,x,yaxis
Region region;// region die klikbaar is om het pijl te bewegen
AlertDialog alertDialog;
LinearLayout layout;
    
public YesNo(Context context) {
    super(context);
    // TODO Auto-generated constructor stub
}
    
@Override
public boolean onTouchEvent(MotionEvent event) {
   //do something
}
 
@Override
protected void onDraw(Canvas canvas) {
    //Do something
    invalidate();
}

i have tried to implement admob with this code(among other):

public void ads() {
    adView = new AdView((Activity) getContext(), AdSize.BANNER,
             "xxxxxxxxxxx");

    LinearLayout.LayoutParams params;
    params = new LinearLayout.LayoutParams(
             LinearLayout.LayoutParams.FILL_PARENT,
             LinearLayout.LayoutParams.WRAP_CONTENT);

    // Create a linear layout
    LinearLayout layout = new LinearLayout((Activity) getContext());
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(6, 6, 6, 6);
    layout.addView(adView, params);
}

I searched hours for a solution but I can’t find any.

Can somebody help me in the right direction?

  • 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-02T23:39:39+00:00Added an answer on June 2, 2026 at 11:39 pm

    First of all, your AdView need to be a part of your content view. The LinearLayout you created in your ads() function. Second, you need to create an AdRequest and load the ad with that request:

    AdRequest request = new AdRequest();
    request.addTestDevice(AdRequest.TEST_EMULATOR); // get test ads on emulator.
    adView.loadAd(request);
    

    Check out the documentation for more information on how to set up your AdView.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement an AdMob ad in my app. I have done
I am trying implement a search activity which gets data from a mysql table
Trying to implement AVAudioplayer and get some metering data of the played music, but
Just trying to implement mobFox into my app, but having trouble to make it
I am trying to implement AdMob in my Application. But dont know somehow its
Trying to implement sticky footer but its not working as planned. It throws it
Trying to implement a UITableView of names similar to the built-in Contacts iPhone app
I'm trying to add an Admob banner to a custom SurfaceView (my main game
SetFocus I'm trying implement the above Se Focus code in a Class Library that
Trying to implement what I thought was a simple concept. I have a user

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.