1

I'm trying to implement Admob banner in Custom Dialog box.

I want to make in in XML 'cause i'm thinking this is simplier to change it positions etc.

So here is fragment from my GameActivity where is Custom Dialog too.

Fragment with dialog:

 public void showRestartDialog() {


    final Dialog dialog = new Dialog(GameActivity.this);

    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

    dialog.setContentView(R.layout.activity_dialog);

    //set up image view
    ImageView img = (ImageView) dialog.findViewById(R.id.imageView1);
    img.setImageResource(R.drawable.puste);

int highest = PrefUtil.getHighestScore(this);
String text = null;
if (currentPoint > highest) {
  highest = currentPoint;
  PrefUtil.setHighestScore(this, currentPoint);
} else {
}
text = "\n  " + currentPoint + "\n\n  " + highest;



   TextView text1 = (TextView)





           dialog.findViewById(R.id.TextView01);
   text1.setText(text);
   AdView adView = (AdView)dialog.findViewById(R.id.adView);
   AdRequest adRequest = new AdRequest.Builder().build();
   adView.loadAd(adRequest);

Where is a problem? With this code, the dialog is showing but without banner. Help me please!

Greetings!

user2393513
  • 109
  • 3
  • 15
  • You should add a listener to the banner. It's possible that an ad isn't available so it isn't getting displayed. That may also show in the log. – Robby Pond Mar 04 '14 at 19:42
  • Hi! Thanks for reply. It's impossible. 'Cause in other place, it's showing ads – user2393513 Mar 04 '14 at 19:53

1 Answers1

0

I don't think you want to do this. An ad can take a long time to load and you may not receive one while the dialog is still displayed. This is probably want you are seeing whne you say that it doesn't show any ad.

You are much better off either showing a banner continuously throughout your app on its main page, or showing an interstitial at the end of the game.

William
  • 20,150
  • 8
  • 49
  • 91