Skip to content

Instantly share code, notes, and snippets.

@burakkurkcu
Created October 15, 2015 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save burakkurkcu/6f2b5a54e2df9d90fffa to your computer and use it in GitHub Desktop.
Save burakkurkcu/6f2b5a54e2df9d90fffa to your computer and use it in GitHub Desktop.
Chartboost libGDX Implementation
public class AndroidLauncher extends AndroidApplication {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
Chartboost.startWithAppId(this, “CHARTBOOST_APP_ID", “CHARTBOOST_APP_SIGNATURE");
Chartboost.onCreate(this);
initialize(new YOUR_MAIN_CLASS(), config);
//usage is same with Android and IOS
//you can use methods after initialization with a location string CBLocation
//Chartboost.hasInterstitial(location)
//Chartboost.cacheInterstitial(location);
//Chartboost.showInterstitial(location);
//and more
}
@Override
public void onActivityResult(int request, int response, Intent data) {
super.onActivityResult(request, response, data);
}
@Override
public void onStart() {
super.onStart();
Chartboost.onStart(this);
}
@Override
public void onStop() {
super.onStop();
Chartboost.onStop(this);
}
@Override
public void onDestroy() {
super.onDestroy();
Chartboost.onDestroy(this);
}
@Override
public void onResume() {
super.onResume();
Chartboost.onResume(this);
}
@Override
public void onPause() {
super.onPause();
Chartboost.onPause(this);
}
}
public class IOSLauncher extends IOSApplication.Delegate {
@Override
protected IOSApplication createApplication() {
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
config.orientationLandscape = false;
config.orientationPortrait = true;
return new IOSApplication(new YOUR_MAIN_CLASS() config);
}
@Override
public void didReceiveMemoryWarning(UIApplication application) {
super.didReceiveMemoryWarning(application);
}
@Override
public void didBecomeActive(UIApplication application) {
super.didBecomeActive(application);
}
@Override
public boolean didFinishLaunching(UIApplication application, UIApplicationLaunchOptions launchOptions) {
System.out.println("IOSLauncher: Finished Launching.”);
//you can implement ChartboostDelegate to listen chartboost related events, didn’t added to keep it simple
Chartboost.start(“CHARTBOOST_APP_ID", “CHARTBOOST_APP_SECRET", new ChartboostDelegateAdapter());
//usage is same with Android and IOS
//you can use methods after initialization with a location string CBLocation
//Chartboost.hasInterstitial(location)
//Chartboost.cacheInterstitial(location);
//Chartboost.showInterstitial(location);
//and more
return super.didFinishLaunching(application, launchOptions);
}
public static void main(String[] argv) {
NSAutoreleasePool pool = new NSAutoreleasePool();
UIApplication.main(argv, null, IOSLauncher.class);
pool.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment