-
Notifications
You must be signed in to change notification settings - Fork 4
Home
Game Distribution edited this page Aug 9, 2014
·
20 revisions
Welcome to the GD-Android-Java wiki!
/**
* Initialize Game Distribution Java API
*
* @param gameId Your game id
* @param regId Your game reg id
* @param _mContext Should be Activity to detect main activity
*/
GDlogger.init(String gameId, String regId, Activity _mContext);
/**
* GDlogger sends how many times 'Play' is called. If you invoke 'Play' many times, it increases 'Play' counter and sends this counter value.
*/
GDlogger.play();
/**
* GDlogger sends how many times 'CustomLog' that is called related to given by _key name. If you invoke 'CustomLog' many times, it increases 'CustomLog' counter and sends this counter value.
*/
GDlogger.customlog(String _key);
/**
* GDlogger enables messages between GDApi and Server
*/
GDlogger.debug(Boolean enable);
package com.example.gdsample;
import com.gd.analytics.GDlogger;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GDlogger.debug(true);
GDlogger.init("xxx", "xxx", this);
// Play Button
Button btnPlay = (Button) findViewById(R.id.btnPlay);
btnPlay.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
GDlogger.play();
}
});
// Custom Button
Button btnCustom = (Button) findViewById(R.id.btnCustom);
btnCustom.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
GDlogger.customlog("Level1");
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}