Git Product home page Git Product logo

admobfullscreen-codenameone's Introduction

admobfullscreen-codenameone

A Codename One library project that uses Admob Interstitial Ads to display full screen ads - https://developers.google.com/mobile-ads-sdk/docs/admob/android/interstitial

The library is implemented for Android, iOS and the Simulator

Thanks for Ram for contributing.(the creator of yhomework)

#Sample Code

public class MyApplication {

private Form current;

private AdMobManager admob;

public void init(Object context) {
    try {
        Resources theme = Resources.openLayered("/theme");
        UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0]));
    } catch(IOException e){
        e.printStackTrace();
    }
    
    String admobId = "<your android adID>";
    if(Display.getInstance().getPlatformName().equals("ios")){
        admobId = "<your iphone adID>";
    }
    admob = new AdMobManager(admobId);
}

public void start() {
    if(current != null){
        current.show();
        return;
    }
    
    Form f = new Form("FullScreen Ads");
    f.addComponent(new Button(new Command("start"){

        public void actionPerformed(ActionEvent evt) {
            admob.loadAd();
        }
    
    }));
    
    f.addComponent(new Button(new Command("show"){

        public void actionPerformed(ActionEvent evt) {
            admob.showAdIfLoaded();
        }
    
    }));

    f.addComponent(new Button(new Command("load & show"){

        public void actionPerformed(ActionEvent evt) {
            admob.loadAndShow();
        }
    
    }));

    f.show();
    
}

public void stop() {
    current = Display.getInstance().getCurrent();
}

public void destroy() {
}

}

#Details

1)Build the project
2)Place the AdmobFullScreen.cn1lib file in your CN1 project lib.
3)Right click on your CN1 project and select "Refresh Libs" then clean build your project.

build for Android -
1)Add the following build hints:
android.xapplication=<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /><activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
android.includeGPlayServices=true

build for iphone -
1)Add the following build hints:
ios.add_libs=AdSupport.framework;SystemConfiguration.framework;CoreTelephony.framework
ios.objC=true

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.