Android API Google Drive“连接失败”

前端之家收集整理的这篇文章主要介绍了Android API Google Drive“连接失败”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我尝试在 Android上使用API​​ Google Drive,首先使用该演示:

https://github.com/googledrive/android-quickstart

但是,我有这个错误,我无法解决.

GoogleApiClient connection Failed:
ConnectionResult{statusCode=SIGN_IN_required,
resolution=PendingIntent{421d40e8: android.os.BinderProxy@42137f78}}

  1. @Override
  2. public void onConnectionFailed(ConnectionResult result) {
  3. // Called whenever the API client fails to connect.
  4. Log.i(TAG,"GoogleApiClient connection Failed: " + result.toString());
  5. if (!result.hasResolution()) {
  6. // show the localized error dialog.
  7. GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(),this,0).show();
  8. return;
  9. }
  10. // The failure has a resolution. Resolve it.
  11. // Called typically when the app is not yet authorized,and an
  12. // authorization
  13. // dialog is displayed to the user.
  14. try {
  15. result.startResolutionForResult(this,REQUEST_CODE_RESOLUTION);
  16. } catch (SendIntentException e) {
  17. Log.e(TAG,"Exception while starting resolution activity",e);
  18. // There was an error with the resolution intent. Try again.
  19. mGoogleApiClient.connect();
  20. }
  21. }
  22.  
  23.  
  24. @Override
  25. protected void onActivityResult(final int requestCode,final int resultCode,final Intent data) {
  26. if (requestCode == REQUEST_CODE_RESOLUTION) {
  27.  
  28. if (resultCode == RESULT_OK) {
  29. Log.i(TAG,"Error resolution success.");
  30.  
  31. // Make sure the app is not already connected or attempting to connect
  32. if (!mGoogleApiClient.isConnecting() &&
  33. !mGoogleApiClient.isConnected()) {
  34. mGoogleApiClient.connect();
  35. }
  36.  
  37. } else {
  38. GooglePlayServicesUtil.getErrorDialog(requestCode,0).show();
  39. }
  40.  
  41. break;
  42. }
  43. }

解决方法

这可能是由于开发人员的疏忽(因为它发生在我身上) – 您在控制台上提供的SHA1详细信息是生产密钥的详细信息,您正在测试调试模式(SHA1详细信息会有所不同).但是,谷歌驱动器API的错误消息可能会更好!

猜你在找的Android相关文章