allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
implementation 'com.github.ahmadidrees347:Admob-Ads:version'
Do not forget to add internet permission in manifest if already not present
<uses-permission android:name="android.permission.INTERNET" />
MobileAds.initialize(this)
val appOpen = AppOpen(application, Constants.AppOpenId)
setAdShownStatus(true/false), if you want to show ad every time then pass true.
appOpen.setAdShownStatus(false)
you can explicitly can call load or show function of appOpen ad:
appOpen.fetchAd { booleanStatus -> }
appOpen.showAdIfAvailable { booleanStatus -> }
For load an ad, call function, you get the result:
loadInterstitial(interAdId) { booleanStatus -> }
To show an ad, call function, you get the result:
showInterstitial(interAdId) { booleanStatus -> }
If you wanted to load an ad and show after loading, then call this function, you can pass any dialog which you want to show before showing an ad.
showInterOnDemand(interAdId, ProgressDialog(this)) { booleanStatus -> }
If you wanted to load every time, auto when user user dismiss an ad:
InterAdmobClass.adLoadAuto = true
You can set failed attempt for inter ad:
InterAdmobClass.adFailedAttempts = 3
Just pass id and frameLayout:
showAdmobBanner(bannerAdId, findViewById(R.id.bannerLayout))
If you wanted to check the banner is loaded or failed then call:
showAdmobBanner(bannerAdId, findViewById(R.id.bannerLayout),{
//success
},{ error ->
//failed
})
Just pass id, frameLayout and layout which you want to inflate:
loadNativeAdmob(
findViewById(R.id.nativeLayout),
nativeAdId,
R.layout.custom_ad_large)
If you wanted to check the native is loaded or failed then call:
loadNativeAdmob(
findViewById(R.id.nativeLayout),
nativeAdId,
R.layout.custom_ad_large,
{
//success
}, { error ->
//failed
})
Copyright (C) 2022
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.