Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 10    Views: 156

mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
06/29/15 03:36 AM (9 years ago)

Tutorial: Admob Banners BT Android 3.0

First if using Android Studio be sure to import Google Play services by going to the Project Structure and importing the Google Play services. In Eclipse be sure to reference the library inside of the project properties.. ========================================== Steps to get Admob Ads Working for Android 1. Open the AndroidManifest.xml Add the following activity at the bottom of the file before </application> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" /> 2. Decide which plugin that you would like to show the banner. In my case I used the BT_screen_customHTML plugin Open the .java file 3. Import the following lines import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.AdView; 4. Go to this line: View thisScreensView = inflater.inflate(R.layout.bt_screen_customhtml, container, false); 5. Below this line add the following code: AdView adView = (AdView) thisScreensView.findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().build(); adView.loadAd(adRequest); 6. Go to the Res/Layout Folder and find the XML file for this plugin. In my case it is: BT_screen_customHTML.xml 7. Confirm that the header for the xml file is: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" 8. Below the </LinearLayout> add the following code: <!-- view for AdMob Banner Ad --> <com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_alignParentBottom="true" ads:adSize="BANNER" ads:adUnitId="ca-app-pub-1111111111/88888888" /> 9. Replace the adUnitID with your id 10. Clean, build and view your ads :)
 
Imagenparaweb
Aspiring developer
Profile
Posts: 121
Reg: Dec 13, 2011
Cordoba
1,210
like
06/30/15 04:13 AM (9 years ago)
Great tutorial. BTW, do you know how set up Admob insterstitial? I'd like to show it every XX minutes on my app.. Do you know how to do that? THanks!
 
fusionmtx
Android Fan
Profile
Posts: 178
Reg: Jun 15, 2011
Orlando
2,180
like
07/02/15 08:41 PM (9 years ago)
I mostly lurk on here......but dang has this helped me out so much! Thanks!!!
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
07/03/15 08:18 AM (9 years ago)
Thanks! LA
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
07/03/15 08:39 AM (9 years ago)
@Imagenpara web .. I haven't tried the interstitial yet. But I assume you follow the same steps but adding different code inside of the java file and I guess you won't need to add anything to the xml layout file.
 
Imagenparaweb
Aspiring developer
Profile
Posts: 121
Reg: Dec 13, 2011
Cordoba
1,210
like
07/03/15 08:47 AM (9 years ago)
Yes, I've done it. But I can't make it appears every XX minutes or maybe when a particular screen reachs 5 views (for example). That's what I want to do..
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
07/03/15 08:48 AM (9 years ago)
ahhh sorry.. you know I had some code to set delay for android. Let me see if i can find it..
 
Imagenparaweb
Aspiring developer
Profile
Posts: 121
Reg: Dec 13, 2011
Cordoba
1,210
like
07/03/15 08:49 AM (9 years ago)
Great! Thanks dude! Let me know if you got it :)
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
07/03/15 08:53 AM (9 years ago)
Check this post: http://www.buzztouch.com/forum/thread.php?tid=0DF4E6F2BC3A4E6DC0BF9B2&currentPage=46 Change the bit here: if(session % 5==0){ // add google code } session++; I believe this is what I was using. Try it out :)
 
Imagenparaweb
Aspiring developer
Profile
Posts: 121
Reg: Dec 13, 2011
Cordoba
1,210
like
07/03/15 08:56 AM (9 years ago)
Good, I'll try it now! Thanks!
 
buzzbt
Android Fan
Profile
Posts: 233
Reg: Nov 14, 2011
las vegas
6,530
like
07/25/15 03:17 AM (8 years ago)
Awesome thanks a lot!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.