Is there a way to load admob ads in an animation thread like draw()?

@akenaton === Sure! This is my test code, here you go:

import android.os.Looper;
import android.os.Bundle;
import android.view.Window;
import android.widget.RelativeLayout;
import android.app.Activity;
//import com.google.ads.*;//
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.MobileAds;
import android.app.Activity;
import android.os.Bundle;

//default values
boolean wasAdOpen = false; 
boolean isMenuOpen = false;

float buttonsize;
AdView adView;
AdRequest newAdReq;
 
void setup() {
  size(displayWidth, displayHeight);
  background(255);
  buttonsize = width/5;
  noStroke();
}

void draw() {
  
  //MAIN APP ACTIVITY (placeholder)
  fill(255);
  rect(0, 0, width, height); 

  //DRAWING THE MENU
  if (isMenuOpen == true) {
    fill(0);
    rect(0, 0, width, height);    
  }
  
  //SHOWING ADS
  if (isMenuOpen == true && wasAdOpen == false) {
    adView.setVisibility(adView.VISIBLE); 
    wasAdOpen = true;
  } else if (isMenuOpen == false && wasAdOpen == true) {
    adView.setVisibility(adView.INVISIBLE);
    wasAdOpen = false;}
   
  //THE MENU BUTTON
  fill(200,0,0);
  circle(width/2,height/10,buttonsize);
}

void mousePressed() {
  //the menu button's hitbox
  if ((width/2 - mouseX <= buttonsize/2 && mouseX - width/2 <= buttonsize/2) 
  && (height/10 - mouseY <= buttonsize/2 && mouseY - height/10 <= buttonsize/2)) {  
    isMenuOpen = !isMenuOpen;
  }
}

@ Override
public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
//here you get the window
Window window = getActivity().getWindow();
//here you add a layout to your window; working with AS or Eclipse you can skip that because you can modify the xml; with processing you have to do that by code
 RelativeLayout adsLayout = new RelativeLayout(this.getActivity());
//here you set the params for your layout
 RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(
    RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT);
 
// now you create your View
 
adView = new AdView(this.getActivity());

adView.setAdSize(AdSize.SMART_BANNER);

adView.setX(0); 
adView.setY(height - 2*(height/10));
 
adView.setAdUnitId("ca-app-pub-3940256099942544/6300978111");
 
// here you add the view to the layout and build your AdRequest
  adsLayout.addView(adView);
    newAdReq = new AdRequest.Builder()
 
// .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)//
 //  .addTestDevice("xxxxxxxxxxxxxxxxx")// this is the id  from your phone for testing; you can get it using TelephonyManager
 
    .build();
 
    adView.loadAd(newAdReq);
    adView.setVisibility(adView.INVISIBLE);
 
///and finally ad the whole stuff to your window
    window.addContentView(adsLayout,lp2);
 
};

(and yes, this is based off of your by now 3 year old code, hehe :slight_smile: )