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

admobfullscreen-codenameone's People

Contributors

chen-fishbein avatar shannah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

admobfullscreen-codenameone's Issues

IOS - Facebook login work every only every other attempt

It seems that consecutive Facebook login work every only every other attempt.
- if the user signs in with Facebook from the first screen everything works 
fine: he is redirected to the main screen of the app and in the My Account 
section from the menu he can see his Facebook credentials (user name and 
profile picture) and the log out button.

- the user can choose to log out from Facebook by clicking the "Log out" 
button. Once this happens, the view is refreshed and the "sign in with 
Facebook" button is shown instead of the "Log out" button. If he chooses to log 
in again with Facebook, the log in fails. I can't see any error messages. The 
user is just left in the same screen. Only, when he clicks "sign in with 
Facebook" button for the third time he is actually logged in and the screen is 
refreshed showing him the Facebook credentials.

This behavior is repetitive, meaning the log in always works the first time, 
the third time, the fifth time etc but it always fails the second time, the 
fourth time, the sixth time etc.

Facebook log in is done like this:

FacebookConnect connect = FacebookConnect.getInstance();

if (connect.isFacebookSDKSupported()) {
connect.setCallback(new LoginCallback() {

@Override
public void loginFailed(String errorMessage) {
Log.p("Login failed: " + errorMessage);

}

@Override
public void loginSuccessful() {
Log.p("Success");
}
});
connect.login();

Please note that when the login fails the error message from loginFailed() is 
blank.

This problem only appears on IOS. On Android the same code works as expected.

Tested on iPad Air with IOS version 8.0.2.

Original issue reported on code.google.com by [email protected] on 15 Jan 2015 at 8:34

Is it possible to get a callback when the user closes the ad?

If I make a call to showAdIfLoaded() or loadAndShow() there is currently no 
callback to know if the user has returned from the ad (timeout or clicking on 
the 'X')

For example, if I'm trying to show an ad between levels in my app, how could I 
know when to begin the next level? Everything happens asynchronously.

I've found a temporary solution, but all of this would be easily solved if the 
showAdIFLoaded() or loadAndShow() could block until the user returns from 
viewing the ad.

Original issue reported on code.google.com by [email protected] on 9 Feb 2015 at 11:06

Google will deprecate SDK

Hi

This is just a warning / reminder, maybe you are already aware of this.

I got a email from Google saying this:

Version 6.4.1 and earlier versions of Google ads SDK for mobile (Android) will become obsolete on September 15, 2016. To ensure that your ads continue after September 15, 2016, update your Google Ads SDK Mobile to version 7.0.0 or later.

Is this cn1lib ready for this?

Shai suggested cocoapods to make the project safe for future releases, although I understand that this solutions will be for iOS only.

https://www.codenameone.com/blog/cocoapods.html

Thanks

No longer compiles for iOS

I tried compiling for iOS with this library about a week ago (with the new iOS compile setup), and it fails. But it compiles without errors for the simulator and Android. Not sure if this means it is an issue with the library or the XCODE 10.1 compile setup.

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.