MediaPlayer song1;
MediaPlayer buttonSound;
int brainEfficiency = 0;
//sound
boolean muted = true;
// int length;
Button BtnSound;
Button BtnGoogleLogin;
//SIGN IN
private static int RC_SIGN_IN = 9001;
private boolean mResolvingConnectionFailure = false;
private boolean mAutoStartSignInflow = true;
private boolean mSignInClicked = false;
boolean mExplicitSignOut = false;
boolean mInSignInFlow = false;
GoogleApiClient mGoogleApiClient;
//ON CREATION
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_title_screen);
//Hide actionbar
getSupportActionBar().hide();
//Setting Flags
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
);
//Music
song1 = MediaPlayer.create(this, R.raw.menu_loop);
song1.setLooping(true);
song1.setVolume(-15, -15);
song1.start();
buttonSound = MediaPlayer.create(this, R.raw.select);
BtnSound = (Button) findViewById(R.id.BtnSound);
BtnGoogleLogin = (Button) findViewById(R.id.BtnGoogleLogin);
//Intializing Other Classes
Animation mAnimation;
mAnimation = new ScaleAnimation(0.9f,1.5f,0.9f,1.5f,Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.45f);
mAnimation.setDuration(300);
mAnimation.setRepeatCount(-1);
mAnimation.setRepeatMode(Animation.REVERSE);
mAnimation.setInterpolator(new AccelerateInterpolator());
Typeface tf = Typeface.createFromAsset(getAssets(), "Obelus.ttf");
//Initializing all Visual Objects
final Button BtnPlay = (Button) findViewById(R.id.BtnPlay);
final Button BtnSettings = (Button) findViewById(R.id.BtnSettings);
final TextView BrainEfficieny = (TextView) findViewById(R.id.TxtBrainFactor);
final TextView label = (TextView) findViewById(R.id.label);
BtnPlay.setBackgroundResource(R.drawable.button1);
BtnSettings.setBackgroundResource(R.drawable.button1);
BtnPlay.setTypeface(tf);
BtnSettings.setTypeface(tf);
BrainEfficieny.setTypeface(tf);
label.setTypeface(tf);
BrainEfficieny.clearAnimation();
BrainEfficieny.startAnimation(mAnimation);
BrainEfficieny.setText(brainEfficiency + "%");
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Games.API)
.build();
}
@Override
public void onStart(){
super.onStart();
mGoogleApiClient.connect();
Log.d("Train your Brain", "Value : " + mGoogleApiClient.isConnected());
}
//PLAY LISTENER
public void onStartClick(View v) {
buttonSound.start();
GameScreen gameScreen = new GameScreen();
Intent IntentGameScreen = new Intent(TitleScreen.this, gameScreen.getClass());
//Deactivate Music
song1.stop();
IntentGameScreen.putExtra("level", 1);
IntentGameScreen.putExtra("path", this.getBaseContext().getFilesDir().getPath());
IntentGameScreen.putExtra("muted", muted);
TitleScreen.this.startActivity(IntentGameScreen);
finish();
}
public void onGoogleLoginClick(View v){
mSignInClicked = true;
mGoogleApiClient.connect();
}
public void onSoundClick(View v){
buttonSound.start();
if (muted){
muted = false;
song1.start();
//song1.seekTo(length); unused cause im using a loop
BtnSound.setBackgroundResource(R.drawable.sound);
}else{
muted = true;
song1.pause();
//length = song1.getCurrentPosition();
BtnSound.setBackgroundResource(R.drawable.no_sound);
}
}
public void onConnectionFailed(ConnectionResult connectionResult){
if(mResolvingConnectionFailure){
return;
}
if (mSignInClicked || mAutoStartSignInflow) {
mAutoStartSignInflow = false;
mSignInClicked = false;
mResolvingConnectionFailure = true;
}
}
@Override
public void onConnected(@Nullable Bundle bundle) {
}
@Override
public void onConnectionSuspended(int i) {
}
如何看到我在登录后调用登录我正在调用一个只发出FALSE的日志方法。所以我其实不知道这个问题。
答案 0 :(得分:0)
认为您需要为该
添加登录APImGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Games.API)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
谷歌在
之前登录选项GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestScopes(new Scope(Scopes.PLUS_LOGIN))
.requestEmail()
.requestProfile()
.build();
来自谷歌的一些关于如何实施登录的例子 https://github.com/googlesamples/google-services/blob/master/android/signin/app/src/main/java/com/google/samples/quickstart/signin/SignInActivity.java