Googleadmob
Googleadmob
steps:
XML
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="YOUR_ADMOB_APP_ID" />
content_copy
o Replace YOUR_ADMOB_APP_ID with your actual AdMob app ID, which you can find in
your AdMob account.
3. Add and initialize the Mobile Ads SDK.
Groovy
implementation 'com.google.android.gms:play-services-ads:20.6.0'
content_copy
o Initialize the Mobile Ads SDK in your app's onCreate() method:
Java
MobileAds.initialize(this);
content_copy
4. Choose an ad format to implement in your app.
o For each ad format that you want to implement, follow the instructions in the
AdMob documentation.
6. Test your ads.
o Once you have implemented ads in your app, test them to make sure that they are
working properly.
o You can do this by using the AdMob test ad unit IDs.
7. Publish your app.
o Once you have tested your ads and are satisfied with them, you can publish your
app to the Google Play Store.
Java
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Load an ad.
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
}
}
Use code with caution. Learn more
content_copy
Once you have implemented ads in your app, you can start earning money from
your app's users