有没有办法设置元数据描述?
https://developer.android.com/reference/com/google/android/gms/drive/Metadata.html#getDescription()
如果是这样,长度限制是多少?
我无法在api中看到任何内容:https://developer.android.com/reference/com/google/android/gms/drive/MetadataChangeSet.Builder.html
答案 0 :(得分:1)
不幸的是,此刻,AFAIK。我现在所做的是初始化GDAA和RESTful API(参见'垃圾解决方案' SO 22295903),如下所示:
private GoogleApiClient _gac;
private com.google.api.services.drive.Drive _svc;
public GoogleApiClient init(String email){
_gac = new GoogleApiClient.Builder(UT.ACTX).addApi(com.google.android.gms.drive.Drive.API)
.addScope(com.google.android.gms.drive.Drive.SCOPE_FILE).setAccountName(email).build();
com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential crd =
GoogleAccountCredential.usingOAuth2(UT.ACTX,
Arrays.asList(com.google.api.services.drive.DriveScopes.DRIVE_FILE));
crd.setSelectedAccountName(email);
_svc = new com.google.api.services.drive.Drive.Builder(
AndroidHttp.newCompatibleTransport(), new GsonFactory(), crd).build();
return this;
}
您可以从DGAA(上面的GoogleApiClient _gac)获取说明,但是像这样更新/写入RESTFul(关闭UI线程):
public void oldDescUpW(String titl, String mime, String desc) {
try {
final FileList gLst = _svc.files().list()
.setQ("title = '"+titl+".jpg' and mimeType = '"+mime+"' and trashed = false")
.setFields("items(id)").execute();
if (gLst.getItems().size() == 1) {
final String sId = gLst.getItems().get(0).getId();
com.google.api.services.drive.model.File body =
new com.google.api.services.drive.model.File();
body.setDescription(desc);
_svc.files().patch(sId, body).execute();
}
} catch (Exception e) {}
}
也可以使用资源ID'来自GDAA来解决RESTful中的文件,但它并不总是立即可用(如果文件是在GDAA中创建的)。见SO 22874657
<强>声明:强>
这是一个HACK,不应该通过GDAA提供替代方案。