This is a complete guide to integrate GreedyGame plugin within your native android game. You can download GreedyGameAgent_v6.jar.
| Original | Dynamic Theme |
|---|---|
![]() |
![]() |
- Paste jar to your android project's libs folder or directly add to build path
Class Overview
Contains high-level classes encapsulating the overall GreedyGame ad flow and model.
Public Constructors
Constructs a new instance of GreedyGame handler.
Method
Lookup for new native campaign from server.
- GameId - Unique game profile id from panel.greedygame.com
- Units - List of relative path of assets used in games. Also register unit id can be used
- FETCH_TYPE - it can be FETCH_TYPE.DOWNLOAD_BY_PATH or FETCH_TYPE.DOWNLOAD_BY_ID, to fetch units by relative path or u_id
Return Theme id of currently active and running theme
Return Theme id of new theme from server
Cancel current campaign download
Return path of folder, where assets of activeTheme is stored.
Floating Ad Method
Fetch floating AdHead with unit-id
Fetch floating AdHead with unit-id, at specific x, y with screen pixels
Hide floating AdHead with unit-id
Analytics Methods As name suggest, put following method inside Andorid main acitivity method.
For example
@Override
protected void onResume(){
super.onResume();
ggAgent.onResume();
}Other Utilities Methods
Return sdk version
Set sdk into debug mode
To use api with HTTPS
Class Overview Is is used as callback listener argument for GreedyAgent class
Methods
response value indicate
* BUSY = loader busy right now
* CAMPAIGN_NOT_AVAILABLE = using no campaign
* CAMPAIGN_CACHED = campaign already cached
* CAMPAIGN_FOUND = new campaign found to download
success true , If new branded contents are downloaded so that new scene can fetch assets from getActivePath().
clicked true, if floating adhead unit is clicked so that game developer can manage game pause.
For example
class GG_Listner implements IAgentListner{
@Override
public void onProgress(float progress) {
//Use this for showing progress bar
Log.i("GreedyGame Sample", "Downloaded = "+progress+"%");
}
@Override
public void onDownload(boolean success) {
if(success){
isBranded = true;
}
}
@Override
public void onInit(OnINIT_EVENT response) {
if( response == OnINIT_EVENT.CAMPAIGN_CACHED ||
response == OnINIT_EVENT.CAMPAIGN_FOUND){
isBranded = true;
}else{
isBranded = false;
}
if(isBranded){
ggAgent.fetchHeadAd("unit-363");
}
}
@Override
public void onUnitClicked(boolean clicked) {
if(clicked) {
//pause game
}else {
//resume/unpause game
}
}
}<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application>
<service
android:name="com.greedygame.android.GreedyBackgroundService"
android:enabled="true" ></service>
<receiver
android:name="com.greedygame.android.GreedyAppReceiver"
android:enabled="true"
android:priority="100">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<action android:name="android.intent.action.PACKAGE_CHANGED" />
<action android:name="android.intent.action.PACKAGE_FIRST_LAUNCH" />
<action android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
<receiver
android:name="com.greedygame.android.GreedyRefReceiver"
android:enabled="true"
android:priority="100">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
</application>To fetch drawable from android res
private Bitmap getBitmapByResid(int resid){
String resName = this.getApplicationContext().getResources().getResourceEntryName(resid);
String[] exts = {"png", "jpg", "gif"};
File file = null;
for(int i = 0; i<exts.length; i++){
file = new File(ggAgent.getActivePath() + "/" + resName+"."+exts[i]);
if(file.exists()){
break;
}
}
if(file == null){
return null;
}
return BitmapFactory.decodeFile(file.getAbsolutePath());
}
