Hello I try to communicate with google drive api on android app, but I see this deprecated by google, how I solve this to my code?
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);
picture with problem: deprecated code picture - line problem
Instead of AndroidHttp, use NetHttpTransport directly or switch to Cronet which is better supported.
Drive googleDriveService = new Drive.Builder(
new NetHttpTransport(),
new GsonFactory(),
credential)
.setApplicationName("Drive API Migration")
.build();
Reference: 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With