我正在尝试运行以下行
credential = GoogleAccountCredential.usingOAuth2(this, DriveScopes.DRIVE);
并收到此错误:
The method usingOAuth2(Context, Collection<String>) in the type GoogleAccountCredential is not applicable for the arguments (GoogleDriveProxeyActivity, String)
然后我将代码更改为:
credential = GoogleAccountCredential.usingOAuth2(this, Arrays.asList(DriveScopes.DRIVE.split(",")));
但是有没有更简单\更简洁的方法来发送正确类型的参数?
最佳答案
DriveScopes 中的所有字符串常量的值(在 the current version of the API !)都是单个范围键,而不是逗号分隔的列表。因此,您应该创建任何合适的集合 - 这是在 Java 中创建大小为 1 的集合的好方法:
Collections.singleton(DriveScopes.DRIVE)
关于java - 如何在java中从单个字符串创建集合<String>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19611773/