Reputation: 405
So I saw multiple guides on forums about ads in Android apps and there is one thing that's been bothering me. Do we, developers need to add Ads in our Application, or Admob will do it for us? Or should we just leave space or something like that? Also when creating account on Admob, which account type should we chose? Individual or business?
Upvotes: 0
Views: 125
Reputation: 36205
When you reference the admob library you create an AdView in your XML layout where the ad will be displayed.
Then in the code, usually in the onCreate method you get the adView by using the findViewById like any other GUI control and then on this reference call. requestAd(adViewReference). (I can't remember the exact code at the top of my head but the official docs are pretty good).
Then when your app loads, it will request a new advert from Admob and if one is available, the advert will be displayed, it will also look at how the advert has been set up, i.e. from the admob web page you can tell an advert to refresh every so many seconds, and the library will automatically do this for you.
Regarding the account type that you select, it really depends on whether you are just an individual developer, i.e. doing it in your spare time or if you are actually a properly registered business.
Hope this helps
UPDATE
Just to clarify slightly, you add an AdView to your XML layout where you want the advert to be designed, as an example, below is one from one of my apps activities
<com.google.android.gms.ads.AdView android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
ads:adUnitId="YOUR_PUBLISHER_ID_FOUND_ON_ADMOB_WEBSITE"
ads:adSize="BANNER"
android:layout_alignParentBottom="true"/>
Then in your activities onCreate method you might have the following to request an advert
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
AdView myAdView = (AdView)findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
myAdView.loadAd(adRequest);
}
Upvotes: 1