mardi 14 juin 2016

Implementing Leaderboards in Android Studio

I have been trying to follow the instructions for implementing Google Play Game Services into my android app, however, Google's instructions @ https://developers.google.com/android/guides/setup are unclear to me.

I added this to my build grade:

dependencies {    

   compile 'com.google.android.gms:play-services:9.0.2'
   compile 'com.google.android.gms:play-services-games:9.0.2'
 }

And this is in my main Activity

import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.SignInButton;

public class LevelOne extends AppCompatActivity {

private static int RC_SIGN_IN = 9001;
private GoogleApiClient mGoogleApiClient;
private boolean mResolvingConnectionFailure = false;
private boolean mAutoStartSignInflow = true;
private boolean mSignInClicked = false;

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_level_one);


  leaderBoardsButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mSignInClicked = true;
            mGoogleApiClient.connect();
        }
    });

There is a crash when this button is clicked, I want the user to be prompted to sign in to Google Play Game Services when they click this button, what am I missing? What do I need to Implement and where do I implement it? Do i need to create a class?

Aucun commentaire:

Enregistrer un commentaire