Created
February 7, 2011 21:10
-
-
Save catchthecows/815227 to your computer and use it in GitHub Desktop.
A quick ScoreNinja test activity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sample.SCNinjaTest; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import android.widget.Button; | |
import android.content.Intent; | |
import com.scoreninja.adapter.*; | |
/* | |
* This is the result of creating a new board at scoreninja.appspot.com: | |
* Congratulations! Created new board for ScoreNinja Test. | |
* Your app id and private key are "sntest-stackoverflow-4910966" and | |
* "8D38475C8ADFB2C82130DA8F8285D392". | |
* | |
* You must pass these to the ScoreNinjaAdapter constructor. | |
* Keep the private key safe! If lost it cannot be retrieved, | |
* and if made public unauthorized scores may be submitted. | |
*/ | |
public class SCNinjaTest extends Activity { | |
private ScoreNinjaAdapter scoreNinjaAdapter; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
// This fails (as expected) | |
scoreNinjaAdapter = new ScoreNinjaAdapter( | |
this, "sntest-stackoverflow-4910966", "8D38475C8ADFB2C82130DA8F8285D392"); | |
setContentView(R.layout.main); | |
Button playlistsbutton = (Button)findViewById(R.id.testscores); | |
playlistsbutton.setOnClickListener(new OnClickListener() { | |
public void onClick(View v) { | |
onGameOver(); | |
} | |
}); | |
} | |
// Unfortunate API, but you must notify ScoreNinja onActivityResult. | |
@Override | |
protected void onActivityResult( | |
int requestCode, int resultCode, Intent data) { | |
super.onActivityResult(requestCode, resultCode, data); | |
scoreNinjaAdapter.onActivityResult( | |
requestCode, resultCode, data); | |
} | |
void onGameOver() { | |
scoreNinjaAdapter.show(200); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment