这是我使用Google Play服务登录测试的完整代码 问题是
result.getStatus().getStatusCode()
return codestatus ..... 12501
我不知道为什么?????
我在
上建立了联系2 https://play.google.com/apps/publish
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private FirebaseAnalytics mFirebaseAnalytics;
private FirebaseAuth mAuth;
private int RC_SIGN_IN = 9003;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Obtain the FirebaseAnalytics instance.
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
findViewById(R.id.sign_in_button).setOnClickListener(this);
mAuth = FirebaseAuth.getInstance();
}
@Override
public void onClick(View view) {
if (view.getId() == R.id.sign_in_button) {
// start the asynchronous sign in flow
startSignInIntent();
}
}
private void startSignInIntent() {
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
.requestServerAuthCode(getString(R.string.default_web_client_id))
.build();
Toast.makeText(this, getString(R.string.default_web_client_id), Toast.LENGTH_SHORT).show();
GoogleSignInClient signInClient = GoogleSignIn.getClient(this,gso);
Intent intent = signInClient.getSignInIntent();
startActivityForResult(intent, RC_SIGN_IN);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
Toast.makeText(this, ""+result.getStatus().getStatusCode(), Toast.LENGTH_SHORT).show();
if (result.isSuccess()) {
// The signed in account is stored in the result.
GoogleSignInAccount signedInAccount = result.getSignInAccount();
} else {
String message = result.getStatus().getStatusMessage();
if (message == null || message.isEmpty()) {
message = getString(R.string.signin_other_error);
}
new AlertDialog.Builder(this).setMessage(message)
.setNeutralButton(android.R.string.ok, null).show();
}
}
}
}
答案 0 :(得分:0)
来自官方文档
指示操作状态。
返回
CommonStatusCodes
public class CommonStatusCodes extends Object
Known Direct Subclasses
通常在API界面之间共享的通用状态代码。
常量摘要
int API_NOT_CONNECTED The client attempted to call a method from an API that failed to connect.
int CANCELED The result was canceled either due to client disconnect or cancel().
int DEVELOPER_ERROR The application is misconfigured.
int ERROR The operation failed with no more detailed information.
int INTERNAL_ERROR An internal error occurred.
int INTERRUPTED A blocking call was interrupted while waiting and did not run to completion.
int INVALID_ACCOUNT The client attempted to connect to the service with an invalid account name specified.
int NETWORK_ERROR A network error occurred.
int RESOLUTION_REQUIRED Completing the operation requires some form of resolution.
int SERVICE_DISABLED This constant was deprecated. This case handled during connection, not during API requests. No results should be returned with this status code.
int SERVICE_VERSION_UPDATE_REQUIRED This constant was deprecated. This case handled during connection, not during API requests. No results should be returned with this status code.
int SIGN_IN_REQUIRED The client attempted to connect to the service but the user is not signed in.
int SUCCESS The operation was successful.
int SUCCESS_CACHE The operation was successful, but was used the device's cache.
int TIMEOUT Timed out while awaiting the result.