This project contains library for easy implementation of ad mob according to ad policies.
Add flowing in maven { url 'https://jitpack.io' }
then following line in app gradle
implementation 'com.github.tariqzia7523:AdsLib:tag'
use your application id
On SplashScreen call following method, for more details look at SplashActivity in app
AddInitilizer(applicationContext,this,BuildConfig.DEBUG).getGDPRConsent("ca-app-pub-3940256099942544~3347511713",object : OnConsentResponse{
override fun onConsentSuccess() {
Toast.makeText(this@SplashActivity, "Suusess", Toast.LENGTH_SHORT).show()
}
override fun onConsentFailure(code: Int, message: String) {
Toast.makeText(this@SplashActivity, "failure", Toast.LENGTH_SHORT).show()
}
})
Open app Ad is with different flow. For this make an application class in that add following code
class App : Application() {
override fun onCreate() {
super.onCreate()
val mySharedPref = MySharedPref(this)
mySharedPref.appOpenID ="orignal_app_id"
AppOpenManager(this, this,mySharedPref,BuildConfig.DEBUG)
}
}
In SplashClass implement OnSplashCallBack on class level and following line in oncreate
AppOpenManager.onSplashCallBack = this
val mySharedPref = MySharedPref(this)
mySharedPref.bannerID = "orignal_banner_id"
mySharedPref.rewardID = "orignal_reward_id"
mySharedPref.nativeID = "orignal_native_id"
mySharedPref.interID = "orignal_interstitial_id"
AddInitilizer.adCounter = 0
you will get method afterOpenAddCallBack. In this must add line
AppOpenManager.onSplashCallBack = null
add adjust furtherFlow
implement interface on class level "OnAdsClosedCallBack" it will give you a method "onCallBack" which will trigger when interstitial call is closed
add following line in onResume Method
val addInitilizer = AddInitilizer(applicationContext,this,BuildConfig.DEBUG)
addInitilizer.showInterstailAdd("Any tag")
you will get same tag in this method which is passed while calling the add yu can use that tag to differ in all further call
addInitilizer.loadBanner(findViewById(R.id.banner_container))
Add Following block in layout
<RelativeLayout
android:id="@+id/add_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/gnt_outline_shape"
android:minHeight="@dimen/_130sdp"
android:layout_marginLeft="@dimen/_10sdp"
android:layout_marginRight="@dimen/_10sdp"
android:layout_marginTop="@dimen/_10sdp"
android:layout_alignParentBottom="true">
<com.module.ads.TemplateView
android:id="@+id/nativeTemplateView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
app:gnt_template_type="@layout/gnt_small_template_view" />
<!-- app:gnt_template_type="@layout/gnt_medium_template_view" -->
<TextView
android:id="@+id/temp_add_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/ad_will_display_hare" />
</RelativeLayout>
Add Following line in backend code
addInitilizer.loadNativeAdd(findViewById(R.id.nativeTemplateView),findViewById(R.id.temp_add_text),findViewById(R.id.add_container))
project has in app purcheses to remove ad calls use following method. addInitilizer.goAddFree()
val list = ArrayList()
val myAdapterForAppList = MyAdapter(this@MainActivity, list)
val admobNativeAdAdapter: AdmobNativeAdAdapter = AdmobNativeAdAdapter.Builder.with( this@MainActivity, myAdapterForAppList, "small", BuildConfig.DEBUG).adItemInterval(8).setContext(this@MainActivity).build()
recylerView.layoutManager = LinearLayoutManager(this@MainActivity)
recylerView.adapter = admobNativeAdAdapter
Add following in Application class
AddInitilizer.madiationInitilization(this)