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

问题描述 投票:0回答:1

您好,我尝试与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

java android google-drive-api
1个回答
0
投票

代替AndroidHttp,直接使用NetHttpTransport或切换到更好支持的Cronet。

参考:NetHttpTransport

© www.soinside.com 2019 - 2024. All rights reserved.