2

Im trying to connect to google fit from my android app. but before doing that I need a connected account. But even if the user select an account the resultCode==0 and I get developer_error as an error. Here is my code

ConnectClass

val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestEmail()
                    .build()
            mGoogleSignInClient = GoogleSignIn.getClient(context, gso)
            val intent: Intent = mGoogleSignInClient.signInIntent

            (context as MainActivity).startActivityForResult(intent, MY_PERMISSIONS_REQUEST)

MainActivity

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        val task =
            GoogleSignIn.getSignedInAccountFromIntent(data)
        if (task.isSuccessful) {
            // Sign in succeeded, proceed with account
            val acct = task.result
        }
    }
DojaB
  • 61
  • 3

0 Answers0