[英]Android: Integrate google drive in app
I have been following this tutorial to integrate google drive in my app. 我一直在按照本教程将google drive集成到我的应用中。 However error occurs when running the app.
但是,在运行应用程序时会发生错误。
The error: 错误:
The following error occured: 400 Bad Request
{
"code":400,
"errors":[{
"domain":"global",
"location":"fiels",
"locationType":"parameter",
"message": "Invalid field selection items",
"reason":"invalidParameter"
}],
"message":"Invalid field selection items"
}
When I debugged this code I found the code is not executing beyond: 当我调试此代码时,我发现该代码没有执行到以下范围:
private List<String> getDataFromApi() throws IOException {
// Get a list of up to 10 files.
List<String> fileInfo = new ArrayList<String>();
FileList result = mService.files().list()
.setPageSize(10)
.setFields("nextPageToken, items(id, name)")
.execute();
Here is the next step from the code that I have used: 这是我使用的代码的下一步:
List<com.google.api.services.drive.model.File> files = result.getFiles();
if (files != null) {
for (com.google.api.services.drive.model.File file : files) {
fileInfo.add(String.format("%s (%s)\n",
file.getName(),file.getId() ));
}
}
return fileInfo;
}
In the manifest I have defined: 在清单中,我定义了:
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
and inside application in manifest: 和清单中的内部应用程序:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.gms.games.APP_ID"
android:value="99102****479" />
<meta-data
android:name="com.google.android.gms.appstate.APP_ID"
android:value="99102****479" />
I don't know what the problem is. 我不知道问题是什么。 Please Help.
请帮忙。 Thank you.
谢谢。
I did the same tutorial a couple of days ago and got same problem, some how they did not updated their tutorial since in this line: 我几天前做了同样的教程,但是遇到了同样的问题,因为在这一行中他们没有更新他们的教程:
.setFields("nextPageToken, items(id, name)")
have to be changed to 必须更改为
.setFields("nextPageToken, files(id, name)")
as they explain in the search for files section . 正如他们在“搜索文件” 部分中所述 。
Hope this helps! 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.