Giter Club home page Giter Club logo

admob-ads's Introduction

Using Admob Ads Library in your Android application

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

Add this in your build.gradle

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" />

For AdMob Ads, initialize it in onCreate() Method of Application/Activity class :

MobileAds.initialize(this)

For AppOpen ads, create an object, passing context & adUnitId in it;

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 Interstitial:

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

For Banner ad,

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
            })

For Native ad,

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
    })

License

   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.

admob-ads's People

Contributors

ahmadidrees347 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

hngdcmnh

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.