Google Drive API
をAndroid用アプリと統合しようとしています。アプリがGoogle Playサービスに問題があります。それでも問題が解決しない場合は、デベロッパーに問い合わせてください。
私のシニアは、自分のマシンからアプリパッケージ名とSHA1
を使用してGoogle Developerコンソールでプロジェクトを作成し、OAuth 2.0
クライアントIDを生成しました(アカウントにアクセスできません)。
ボタンをクリックすると、ドライブ上のファイルにアクセスしてサーバーにアップロードできるようにする必要があります。
私は、次のコードonClick()
呼び出す:
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Log.i(TAG, "Connection failed");
if (connectionResult.hasResolution()) {
try {
Log.i(TAG, "Connection failed - Trying again");
connectionResult.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE);
} catch (IntentSender.SendIntentException e) {
// Unable to resolve, message user appropriately
}
} else {
Log.i(TAG, "Connection failed, Code : " + connectionResult.getErrorCode());
GooglePlayServicesUtil.getErrorDialog(connectionResult.getErrorCode(), this, 0).show();
}
}
接続が失敗し、それが再び試みます。これは、onConnectionFailed()
コールバックを呼び出し
mGoogleApiClient = new GoogleApiClient.Builder(Activity.this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(Activity.this)
.addOnConnectionFailedListener(Activity.this)
.build();
mGoogleApiClient.connect();
を。再試行では、それはonActivityResult()
を呼び出し、再度接続を試みます。Googleと
public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
if (requestCode == Constants.RESOLVE_CONNECTION_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
Log.i(TAG, "Code match");
mGoogleApiClient.connect();
}
}
再接続試行は、エラーコード8と、失敗したメッセージを与えます。この時、「アプリケーションが持っているトラブルがサービスを再生する問題が解決しない場合は開発者に問い合わせてください。
私もこれを読んでいます: <Your App> is having trouble with Google Play services - When using GoogleApiClient, it always trigger onConnectionFailedしかし、助けになりませんでした。
私はGoogleで調べてみましたが、まだ何も助けていません。どんな援助も素晴らしいでしょう!
はい。私はそれを確認した。しかし、これはアカウント選択ダイアログが 'onResume()'をポップアップさせる原因になります。私はそれを望んでいない。ユーザーがGoogleドライブからファイルにアクセスしたい場合にのみ、そのダイアログを表示します。 – Bot