Elad Benda
Elad Benda

Reputation: 36664

how to create a Collection<String> out of a single String in java?

I'm trying to run this following line

credential = GoogleAccountCredential.usingOAuth2(this, DriveScopes.DRIVE);

and get this error:

The method usingOAuth2(Context, Collection<String>) in the type GoogleAccountCredential is not applicable for the arguments (GoogleDriveProxeyActivity, String)

I then changed the code to this:

credential = GoogleAccountCredential.usingOAuth2(this, Arrays.asList(DriveScopes.DRIVE.split(",")));

but is there a simpler\neater way to send the proper type of param?

Upvotes: 2

Views: 1065

Answers (1)

Robin Green
Robin Green

Reputation: 33083

The values of all the string constants in DriveScopes (in the current version of the API!) are single scope keys, not comma-separated lists. So, you should create any suitable collection - this is a nice way to create a collection of size 1 in Java:

Collections.singleton(DriveScopes.DRIVE)

Upvotes: 3

Related Questions