About :-Grow your business with Chartboost
The largest mobile games-only platform to increase revenue and discover new players.
Platform :-
- Android
- iOS
- Amazon
- unity
- Adobe air
- COCOC 2D
Payment Method & Terms :-
- Paypal
- ACH
We pay publishers net 45 days after the month’s end in which earnings reach $75. We also require a completed/signed tax form to remit payments.
—> Frist Open chartboost Account And Get App ID :- 54e3009104b0166877d3ef09. App Signatured :- f5b35ffe34af2607877300d69f2bf47dbee3183.
After Getting All Information Start Eclipse And Create New Project.
—> AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="com.android.vending.BILLING" /> <activity android:name="com.chartboost.sdk.CBImpressionActivity" android:excludeFromRecents="true" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
–> Open Layout.xml File.
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fillViewport="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="#FFFFFF" android:orientation="vertical"> <ImageView android:layout_width="300dp" android:layout_height="102dp" android:background="@drawable/leaf_border_top_left" android:layout_gravity="center" android:padding="5dp" /> <ImageView android:layout_width="50dp" android:layout_height="50dp" android:background="@drawable/logo" android:layout_gravity="center" android:padding="10dp" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="70dp" android:layout_marginTop="20dp" android:orientation="horizontal" > <Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="10dp" android:layout_weight="0.5" android:background="@drawable/btnpress" android:onClick="onLoadButtonClick" android:text="@string/load_interstitial" > </Button> <Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="10dp" android:layout_weight="0.5" android:background="@drawable/btnpress" android:onClick="onPreloadClick" android:text="@string/preload_interstitial"> </Button> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="70dp" android:orientation="horizontal" > <Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="10dp" android:layout_weight="0.5" android:background="@drawable/btnpress" android:onClick="onLoadVideoClick" android:text="@string/load_video" > </Button> <Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="10dp" android:layout_weight="0.5" android:background="@drawable/btnpress" android:onClick="onPreloadVideoClick" android:text="@string/preload_video" > </Button> </LinearLayout> <!-- Button android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="0.12" android:text="Perform Test Click" android:id="@+id/button1" android:onClick="onPerformTestClick"></Button --> <LinearLayout android:layout_width="fill_parent" android:layout_height="70dp" android:orientation="horizontal" > <Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="10dp" android:layout_weight="0.5" android:background="@drawable/btnpress" android:onClick="onMoreButtonClick" android:text="@string/more_apps" > </Button> <Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="10dp" android:layout_weight="0.5" android:background="@drawable/btnpress" android:onClick="onPreloadMoreAppsClick" android:text="@string/preload_more_apps" > </Button> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="70dp" android:orientation="horizontal" > <Button android:layout_width="40dp" android:layout_height="40dp" android:layout_margin="10dp" android:layout_weight="0.5" android:background="@drawable/btnpress" android:onClick="onInPlayButtonClick" android:text="@string/load_inplay" > </Button> <Button android:layout_width="40dp" android:layout_height="40dp" android:layout_margin="10dp" android:layout_weight="0.5" android:background="@drawable/btnpress" android:onClick="onPreloadInPlayButtonClick" android:text="@string/preload_inplay" > </Button> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="70dp" android:orientation="horizontal" > <ImageView android:id="@+id/inplayView" android:layout_width="10dp" android:layout_height="40dp" android:layout_margin="20dp" android:layout_weight="0.5" > </ImageView> </LinearLayout> </LinearLayout> </ScrollView>
open SampleActivity.java file…
import android.annotation.SuppressLint; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.view.Window; import android.widget.ImageView; import android.widget.Toast; import com.chartboost.sdk.CBLocation; import com.chartboost.sdk.Chartboost; import com.chartboost.sdk.ChartboostDelegate; import com.chartboost.sdk.InPlay.CBInPlay; import com.chartboost.sdk.Libraries.CBLogging.Level; import com.chartboost.sdk.Model.CBError.CBClickError; import com.chartboost.sdk.Model.CBError.CBImpressionError; public class SampleActivity extends Activity { private static final String TAG = "Chartboost"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); Chartboost.startWithAppId(this, getResources().getString(R.string.appId), getResources().getString(R.string.appSignature)); Chartboost.setLoggingLevel(Level.ALL); Chartboost.setDelegate(delegate); Chartboost.onCreate(this); setContentView(R.layout.main); } @Override protected void onStart() { super.onStart(); Chartboost.onStart(this); } @Override protected void onStop() { super.onStop(); Chartboost.onStop(this); } @Override protected void onPause() { super.onPause(); Chartboost.onPause(this); } @Override protected void onResume() { super.onResume(); Chartboost.onResume(this); } @Override public void onBackPressed() { // If an interstitial is on screen, close it. Otherwise continue as normal. if (Chartboost.onBackPressed()) return; else super.onBackPressed(); } @Override protected void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); Chartboost.onDestroy(this); } public void onLoadButtonClick(View view) { String toastStr = "Loading Interstitial"; if (Chartboost.hasInterstitial(CBLocation.LOCATION_LEADERBOARD)) toastStr = "Loading Interstitial From Cache"; Log.i(TAG, toastStr); Chartboost.showInterstitial(CBLocation.LOCATION_LEADERBOARD); } public void onMoreButtonClick(View view) { String toastStr = "Loading More Apps"; if (Chartboost.hasMoreApps(CBLocation.LOCATION_GAME_SCREEN)) toastStr = "Loading More Apps From Cache"; Log.i(TAG, toastStr); Chartboost.showMoreApps(CBLocation.LOCATION_GAME_SCREEN); } public void onPreloadClick(View v) { Log.i(TAG, "Preloading Interstitial Ad"); Chartboost.cacheInterstitial(CBLocation.LOCATION_LEADERBOARD); } public void onPreloadMoreAppsClick(View v) { Log.i(TAG, "Preloading More apps Ad"); Chartboost.cacheMoreApps(CBLocation.LOCATION_GAME_SCREEN); } public void onLoadVideoClick(View view) { String toastStr = "Loading Rewarded Interstitial"; if (Chartboost.hasRewardedVideo(CBLocation.LOCATION_ACHIEVEMENTS)) toastStr = "Loading Rewarded Interstitial From Cache"; Log.i(TAG, toastStr); Chartboost.showRewardedVideo(CBLocation.LOCATION_ACHIEVEMENTS); } public void onPreloadVideoClick(View v) { Log.i(TAG, "Preloading Rewarded Interstitial Ad"); Chartboost.cacheRewardedVideo(CBLocation.LOCATION_ACHIEVEMENTS); } private ChartboostDelegate delegate = new ChartboostDelegate() { @Override public boolean shouldRequestInterstitial(String location) { Log.i(TAG, "SHOULD REQUEST INTERSTITIAL '"+ (location != null ? location : "null")); return true; } @Override public boolean shouldDisplayInterstitial(String location) { Log.i(TAG, "SHOULD DISPLAY INTERSTITIAL '"+ (location != null ? location : "null")); return true; } @Override public void didCacheInterstitial(String location) { Log.i(TAG, "DID CACHE INTERSTITIAL '"+ (location != null ? location : "null")); } @Override public void didFailToLoadInterstitial(String location, CBImpressionError error) { Log.i(TAG, "DID FAIL TO LOAD INTERSTITIAL '"+ (location != null ? location : "null")+ " Error: " + error.name()); Toast.makeText(getApplicationContext(), "INTERSTITIAL '"+location+"' REQUEST FAILED - " + error.name(), Toast.LENGTH_SHORT).show(); } @Override public void didDismissInterstitial(String location) { Log.i(TAG, "DID DISMISS INTERSTITIAL: "+ (location != null ? location : "null")); } @Override public void didCloseInterstitial(String location) { Log.i(TAG, "DID CLOSE INTERSTITIAL: "+ (location != null ? location : "null")); } @Override public void didClickInterstitial(String location) { Log.i(TAG, "DID CLICK INTERSTITIAL: "+ (location != null ? location : "null")); } @Override public void didDisplayInterstitial(String location) { Log.i(TAG, "DID DISPLAY INTERSTITIAL: " + (location != null ? location : "null")); } @Override public boolean shouldRequestMoreApps(String location) { Log.i(TAG, "SHOULD REQUEST MORE APPS: " + (location != null ? location : "null")); return true; } @Override public boolean shouldDisplayMoreApps(String location) { Log.i(TAG, "SHOULD DISPLAY MORE APPS: " + (location != null ? location : "null")); return true; } @Override public void didFailToLoadMoreApps(String location, CBImpressionError error) { Log.i(TAG, "DID FAIL TO LOAD MOREAPPS " + (location != null ? location : "null")+ " Error: "+ error.name()); Toast.makeText(getApplicationContext(), "MORE APPS REQUEST FAILED - " + error.name(), Toast.LENGTH_SHORT).show(); } @Override public void didCacheMoreApps(String location) { Log.i(TAG, "DID CACHE MORE APPS: " + (location != null ? location : "null")); } @Override public void didDismissMoreApps(String location) { Log.i(TAG, "DID DISMISS MORE APPS " + (location != null ? location : "null")); } @Override public void didCloseMoreApps(String location) { Log.i(TAG, "DID CLOSE MORE APPS: "+ (location != null ? location : "null")); } @Override public void didClickMoreApps(String location) { Log.i(TAG, "DID CLICK MORE APPS: "+ (location != null ? location : "null")); } @Override public void didDisplayMoreApps(String location) { Log.i(TAG, "DID DISPLAY MORE APPS: " + (location != null ? location : "null")); } @Override public void didFailToRecordClick(String uri, CBClickError error) { Log.i(TAG, "DID FAILED TO RECORD CLICK " + (uri != null ? uri : "null") + ", error: " + error.name()); Toast.makeText(getApplicationContext(), "FAILED TO RECORD CLICK " + (uri != null ? uri : "null") + ", error: " + error.name(), Toast.LENGTH_SHORT).show(); } @Override public boolean shouldDisplayRewardedVideo(String location) { Log.i(TAG, String.format("SHOULD DISPLAY REWARDED VIDEO: '%s'", (location != null ? location : "null"))); return true; } @Override public void didCacheRewardedVideo(String location) { Log.i(TAG, String.format("DID CACHE REWARDED VIDEO: '%s'", (location != null ? location : "null"))); } @Override public void didFailToLoadRewardedVideo(String location, CBImpressionError error) { Log.i(TAG, String.format("DID FAIL TO LOAD REWARDED VIDEO: '%s', Error: %s", (location != null ? location : "null"), error.name())); Toast.makeText(getApplicationContext(), String.format("DID FAIL TO LOAD REWARDED VIDEO '%s' because %s", location, error.name()), Toast.LENGTH_SHORT).show(); } @Override public void didDismissRewardedVideo(String location) { Log.i(TAG, String.format("DID DISMISS REWARDED VIDEO '%s'", (location != null ? location : "null"))); } @Override public void didCloseRewardedVideo(String location) { Log.i(TAG, String.format("DID CLOSE REWARDED VIDEO '%s'", (location != null ? location : "null"))); } @Override public void didClickRewardedVideo(String location) { Log.i(TAG, String.format("DID CLICK REWARDED VIDEO '%s'", (location != null ? location : "null"))); } @Override public void didCompleteRewardedVideo(String location, int reward) { Log.i(TAG, String.format("DID COMPLETE REWARDED VIDEO '%s' FOR REWARD %d", (location != null ? location : "null"), reward)); } @Override public void didDisplayRewardedVideo(String location) { Log.i(TAG, String.format("DID DISPLAY REWARDED VIDEO '%s' FOR REWARD", location)); } @Override public void willDisplayVideo(String location) { Log.i(TAG, String.format("WILL DISPLAY VIDEO '%s", location)); } }; @SuppressLint("ClickableViewAccessibility") public void onInPlayButtonClick(View view) { String toastStr = "Loading InPlay"; Log.i(TAG, toastStr); Toast.makeText(this, toastStr, Toast.LENGTH_SHORT).show(); final CBInPlay inPlay = CBInPlay.getInPlay(CBLocation.LOCATION_GAMEOVER); if(inPlay != null) { ImageView myview = (ImageView) findViewById(R.id.inplayView); myview.setImageBitmap(inPlay.getAppIcon()); inPlay.show(); myview.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { inPlay.click(); return false; } }); } } public void onPreloadInPlayButtonClick(View view) { String toastStr = "Preloading InPlay"; Log.i(TAG, toastStr); CBInPlay.cacheInPlay(CBLocation.LOCATION_GAMEOVER); } }
—> Run Your Code.
Leave a Reply