I'm using google admob to place ads in my app, however I have some questions
My code (summarized):
public class MainActivity extends AppCompatActivity {
private InterstitialAd mInterstitialAd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MobileAds.initialize(this, "ca-app-pub-5718158120252618~4586568420");
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
carregarAnuncio();
mInterstitialAd.setAdListener(new AdListener(){
@Override
public void onAdClosed() {
carregarAnuncio();
}
});
banco.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
mInterstitialAd.show();
onibus.clear();
for(DataSnapshot data: dataSnapshot.getChildren()){
BusAdmin b = data.getValue(BusAdmin.class);
b.setKey(data.getKey());
onibus.add(b);
}
adapter.notifyDataSetChanged();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
private void carregarAnuncio() {
mInterstitialAd.loadAd(new AdRequest.Builder().build());
}
}
For the time being the ad is only loaded after the bank (firebase) I want the exact opposite