java - How to set "pageSize" with the java client of the Google Photos API
问题描述
We are using the Google Photos API java client on Android to retrieve some of the user's photo with this code:
try(PhotosLibraryClient photosLibraryClient = PhotosLibraryClient.initialize(settings)) {
InternalPhotosLibraryClient.SearchMediaItemsPagedResponse libraryResponse = photosLibraryClient.searchMediaItems(filters);
Iterable<InternalPhotosLibraryClient.SearchMediaItemsPage> listMediaItemsPage = libraryResponse.iteratePages();
for (InternalPhotosLibraryClient.SearchMediaItemsPage mediaItemsPage : listMediaItemsPage) {
/* ... */
}
}
Our problem is that the mediaItemsPage
only retrieve up to 25 mediaItem
by default. According to the Google Photos API it's possible to move that number up to 100 by setting the "pageSize" parameter. However when using the Java client we cannot find how to correctly set this parameter.
There is a libraryResponse.iterateFixedSizeCollections(collectionSize);
but looking at the method's doc it says:
it is an error to call this method if the optional parameter 'page_size' has not been * set in the original API call. It is also an error if the collectionSize parameter is less than * the page_size.
What is the "original API call"? What are the steps required in order to set pageSize
correctly?
解决方案
推荐阅读
- android - Dagger2:ViewModel 中的字段注入,具有编译时和运行时依赖项
- docker - 尝试使用 Docker Nginx 和 Certbot 获取 SSL
- android - 增强现实的现实世界对象识别
- excel - 使用 VBA 解析和扩展具有变量的代数方程
- android - FinishAffinity android 5.0 上的 NPE
- python - 无法覆盖flask_bootstrap css
- python-3.x - 来自 pymysql 的 Mysql 连接
- javascript - Javascript 语法错误:缺失
- android - 在Imageview中设置图像,其中图像的路径存储在sqlite数据库中,实际图像存储在drawable中
- xamarin - Xamarin Forms 输入点击不会显示整个宽度的键盘