How to add banner in Custom Dialog?

2,824 views
Skip to first unread message

sweets...@gmail.com

unread,
Mar 4, 2014, 3:00:46 PM3/4/14
to google-adm...@googlegroups.com
Hi guys!

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!

Amy Quispe (AdMob SDK Team)

unread,
Mar 4, 2014, 6:59:13 PM3/4/14
to google-adm...@googlegroups.com
Hi there,

Is your AdView created correctly in the XML? I can't see it here, but feel free to copy/paste so I can take a look.

You might want to attach an AdListener to see if the Ad is even loading.

Amy Quispe

sweets...@gmail.com

unread,
Mar 4, 2014, 7:12:43 PM3/4/14
to google-adm...@googlegroups.com
Here:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:ads="http://schemas.android.com/apk/res-auto"
              android:orientation="vertical"
              android:visibility="visible"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-2111998585475142/5214723513" >
    </com.google.android.gms.ads.AdView>

</LinearLayout>
    


Amy Quispe (AdMob SDK Team)

unread,
Mar 4, 2014, 7:32:01 PM3/4/14
to google-adm...@googlegroups.com
Hi there,

Looks like everything is done correctly here. Is your manifest file set up correctly?

Amy Quispe

sweets...@gmail.com

unread,
Mar 5, 2014, 9:50:33 AM3/5/14
to google-adm...@googlegroups.com

Do I get banned on admob?

Yes of course, Manifest is OK.

But ok, I want to implement it in other place, but I don't know is legal. Exactly here:


Amy Quispe (AdMob SDK Team)

unread,
Mar 6, 2014, 7:20:19 PM3/6/14
to google-adm...@googlegroups.com
HI there,

It's okay to put your banner there, but you might want it to not show during game play for a better user experience.

Amy Quispe
Reply all
Reply to author
Forward
0 new messages