我想将文件夹名称传递给我的函数并在我已登录的Google帐户中创建该文件夹
有我的SignInOptions
mGoogleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestScopes(new Scope(Scopes.DRIVE_FULL))
.requestScopes(Drive.SCOPE_FILE)
.requestScopes(Drive.SCOPE_APPFOLDER)
.requestEmail()
.build();
mGoogleSignInClient = GoogleSignIn.getClient(this, mGoogleSignInOptions);
account = GoogleSignIn.getLastSignedInAccount(this);
这是我的功能。
private void createFoler(String folderName) {
mDriveResourceClient = Drive.getDriveResourceClient(this, account);
mDriveResourceClient.getRootFolder()
.continueWithTask(task -> {
DriveFolder parentFolder = task.getResult();
MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
.setTitle(folderName)
.setMimeType(DriveFolder.MIME_TYPE)
.setStarred(true)
.build();
return mDriveResourceClient.createFolder(parentFolder, changeSet);
});
}
错误消息:
Unable to create file:com.google.android.gms.common.api.ApiException: 17: Error resolution was canceled by the user, original error message: INTERNAL_ERROR: null
我需要设置哪些配置?感谢
答案 0 :(得分:0)
我认为这是由于范围所致,因为我看到您正在尝试Drive_Full
注意:Google Drive Android API当前仅支持drive.file和drive.appfolder授权范围。如果您的应用程序需要其他权限或Drive Android API中尚不可用的功能,则必须使用Google API Java Client。
您可以阅读更多here