Hello I was trying to implement Admob Banner in Splash Screen and have just succeeded after trying many times because I am not a programmer , if anyone else want to try just follow the simple steps I have written, it will hardly take 10 minutes, 320x50 will be the banner size, check here 1. First open a account for Admob and then create App inside Admob account, you will get your Publisher ID for your app, for details click here 2. Then download Admob sdk, click here 2. Now unzip your folder, you will get GoogleAdMobAdsSdk-6.4.1.jar. 3. Create a "libs" folder in Eclipse under your project and copy the .jar file there (like you do with Leadbolt sdk). 4. Now right click on your project and go to "Build Path > Configure Build Path > Libraries" and then add the .jar file from "libs" folder to your libraries (the same way you do for Leadbolt). 5. Now open your Manifest.xml and just copy paste the following user permissions. If you already have it then leave it. Code (text): <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 6. Now add a Activity in your Manifest.xml, just copy paste from below Code (text): <!-- Admob Ad--> <activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" ></activity> 7. Now open your Splash.xml and add the following code right after this line <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" Code (text): xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 8. Now add the following code in the same file (Splash.xml) where you would like to display your ad for Splash Screen. If you want to display at the bottom then just copy paste the code right above </LinearLayout> tag. Code (text): <com.google.ads.AdView android:id="@+id/ad" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="40dp" android:gravity="center" ads:adUnitId="Copy Paste Admob Ad Publisher ID Here" ads:loadAdOnCreate="true" ads:adSize="BANNER" /> 9. Last and the final thing, copy paste your Ad Publisher ID in the above code. 10. Now compile your .apk and test on your device with Data Connection/Wifi ON. 11. The Result
How'd you manage to get your splash activity menu screen to look so bad ass? and anyone have any idea on how to do this with leadbolt banner ads or entry and exit ads? Same process different code I'm guessing?
@Friendlyspeaking nice tutorial, and what about adding interstitial in the splash,may I use the same codes for interstitials
@fatos I did not get this error, you can check this http://stackoverflow.com/questions/7899767/admob-error-in-eclipse-for-androidconfigchanges
Hey, have you found out how to ad interstitial advertisements to the splash screen also? As well as the settings menu? Both banner ads and interstitial ads? If you did I'd really appreciate it if you helped me out. D:
@fatos for banner in Splash screen there is no need to add anything in Splash.java you can check the above link for the error. @Joshua I did not try to implement interstitial ad so I cannot tell about it
Alright man well lemme know when you do! I spent all day trying to figure it out I had no luck would be awesome. How about banner ads figure out how to put that in the settings menu yet? ^,^
Hello Joshua Follow the Steps for adding Admob banner in Settings menu 1. Create a xml file in res > layout > admob.xml 2. Leave the xml file as it is, Admob banner will automatically be filled in this later. 3. Create a class file in src > com.sbg.lwc > AdPreference.java 4. Copy Paste the following code in java file. Code (text): package com.sbg.lwc; import com.google.ads.AdRequest; import com.google.ads.AdSize; import com.google.ads.AdView; import android.app.Activity; import android.content.Context; import android.preference.Preference; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; public class AdPreference extends Preference { public AdPreference(Context context, AttributeSet attrs, int defStyle) {super (context, attrs, defStyle);} public AdPreference(Context context, AttributeSet attrs) {super(context, attrs);} public AdPreference(Context context) {super(context);} @Override protected View onCreateView(ViewGroup parent) { // this will create the linear layout defined in ads_layout.xml View view = super.onCreateView(parent); // the context is a PreferenceActivity Activity activity = (Activity)getContext(); // Create the adView AdView adView = new AdView(activity, AdSize.BANNER, "banner code"); ((LinearLayout)view).addView(adView); // Initiate a generic request to load it with an ad AdRequest request = new AdRequest(); adView.loadAd(request); return view; } } 5. Change your Admob banner code in the above code. 6. Now open your lwp_settings.xml and put the following code where you would like to display ad Code (text): <com.sbg.lwc.AdPreference android:layout="@layout/admob"/> 7. I have put the code in the following way in this example Code (text): <PreferenceCategory android:title="Preferences" android:key="main_preference_category"> <com.sbg.lwc.AdPreference android:layout="@layout/admob"/> 8. Now check on your mobile 9. Result
@Friendlyspeaking I already checked the link above, can you send me a pic of your Android SDK Manager please, I think this isssue is related whith Android SDK's
Follow the steps for Admob Interstitials in Splash Screen 1. Make sure you have added the following activity in Manifest.xml Code (text): <!-- Admob Ad--> <activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"></activity> 2. Now open your Splash.java and add the following codes in import. Code (text): import com.google.ads.*; import com.google.ads.AdRequest.ErrorCode; 3. Now copy paste the following code after this line > public class Splash extends Activity{ Code (text): private InterstitialAd interstitial; 4. Now copy paste the following codes after this line > setContentView(R.layout.splash); Code (text): interstitial = new InterstitialAd(this, "Enter Your Interstitial Ad Code Here"); AdRequest adRequest = new AdRequest(); interstitial.loadAd(adRequest); interstitial.setAdListener(this); 5. Copy paste your Interstitial ad code in the above code. 6. Now if you see error in "interstitial.setAdListener(this);" move your mouse over it for quick fixes and click on "Let 'Splash' implement 'AdListner'" 7. Now if you see error in "Public class Splash extends Activity" then move your mouse over it for quick fixes and click on "Add unimpltemented methods" 8. Now scroll down at the bottom. 9. Replace the following code Code (text): @Override public void onReceiveAd(Ad arg0) { // TODO Auto-generated method stub } ^ Replace this with the following one public void onReceiveAd(Ad ad) { Log.d("OK", "Received ad"); if (ad == interstitial) { interstitial.show(); } } 10. Now if you see error here move your mouse over Log.d and click on "Import 'Log' (android.util)" 11. Check on your mobile 12. Result
I also liked the Interstitials, this is huge and it loads fast .... but do you know if we can use both the ads Admob + Leadbolt on the same screen?
Yes I believe you can. Try implementing both admob and leadbolt sdks then adding the leadbolt ad into the desired location and make sure that one takes a bit longer than the other to show up and that should do the trick. ^,^