我试图从我的 android 应用程序连接到 google fit。但在此之前,我需要一个关联帐户。但是,即使用户选择了一个帐户,resultCode==0 我也会得到 developer_error 作为错误。这是我的代码
连接类
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)
主要活动
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
}
}