gpt4 book ai didi

java - com.google.api.client.extensions.android.http.androidhttp 已弃用

转载 作者:行者123 更新时间:2023-12-01 17:07:03 31 4
gpt4 key购买 nike

您好,我尝试在 Android 应用程序上与 google Drive api 进行通信,但我看到 Google 已弃用此功能,我如何在代码中解决此问题?

    void fun(GoogleSignInAccount signInAccount){
Log.d("jjj","fun called");
GoogleAccountCredential credential =
GoogleAccountCredential.usingOAuth2(
this, Collections.singleton(DriveScopes.DRIVE_FILE));
credential.setSelectedAccount(signInAccount.getAccount());
Drive googleDriveService =
new Drive.Builder(
AndroidHttp.newCompatibleTransport(),
new GsonFactory(),
credential)
.setApplicationName("Drive API Migration")
.build();
editor.putBoolean("SyncOn",true).commit();
mDriveServiceHelper = new DriveServiceHelper(googleDriveService);

有问题的图片: deprecated code picture - line problem

最佳答案

使用 NetHttpTransport 而不是 AndroidHttp直接或者切换到支持更好的Cronet。

Drive googleDriveService = new Drive.Builder(
new NetHttpTransport(),
new GsonFactory(),
credential)
.setApplicationName("Drive API Migration")
.build();

引用:https://github.com/googleapis/google-http-java-client/blob/master/google-http-client-android/src/main/java/com/google/api/client/extensions/android/http/AndroidHttp.java#L35

关于java - com.google.api.client.extensions.android.http.androidhttp 已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61456919/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com