Make Money Online BANNERS Adding Admob Banner Ads into Android Apps

Adding Admob Banner Ads into Android Apps

Adding Admob Banner Ads into Android Apps post thumbnail image


Developers looking to monetize their Android apps can do so by integrating Admob banner ads into their app. Admob is a mobile advertising platform that helps developers monetize their apps by displaying ads to users. Admob banner ads are displayed as rectangular banners at the top or bottom of an app’s screen. When a user clicks on an ad, the developer earns money.

Admob banner ads are a great way for developers to monetize their Android apps. They are easy to integrate and offer a variety of ad formats to choose from. Admob also offers high fill rates, which means that there is a good chance that an ad will be displayed every time a user opens an app.

To integrate Admob banner ads into your Android app, you will need to create a new project in Android Studio. Then, open the build.gradle file and add the following dependency: compile ‘com.google.android.gms:play-services-ads:11+’. Next, open the MainActivity.java file and add the following code:

import com.google.android.gms.ads.*;

public class MainActivity extends AppCompatActivity {

private AdView mAdView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// Create an ad request and display it in the activity layout XML file.
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest .Builder() .build(); // Display the ad view on screen mAdView .loadAd(adRequest); } } }
The code above will display a banner ad at the bottom of your app’s screen when it is opened. You can also display an interstitial ad by adding the following code:

import com .google .android .gms .ads .InterstitialAd ; public class MainActivity extends AppCompatActivity { private InterstitialAd mInterstitialAd ; @Override protected void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ); setContentView ( R . layout . activity_main ); // Create an InterstitialAd object and load an ad with ID “my_ad”. mInterstitialAd = new InterstitialAd ( this ); mInterstitialAd . setAdunitId ( “ca-app-pub-3940256099942544/8691691433” ); mInterstitialAd . loadAd ( new AdRequest (). Builder (). Build ()); } public void showInterstitial () { // Show the interstitial if it’s ready if ( mInterstitialAd != null && mInterstitialAd . isLoaded () ) { mInterstitialAd . show (); } else { // Proceed without showing an interstitial Log . d ( “TAG” , “The interstitial wasn’t loaded yet.” ); } } // … @Override public void onDestroy () { super . onDestroy (); release (); } private void release () { // Destroy the interstitial if it’s not null if ( mInterstitialAd != null ) { mInterstitialAd = null ; } }}
The code above will display an interstitial ad when the showInterstitial() method is called

Related Post