问题
First, everything looked OK until yesterday (Mar 12, 2014). Since about lunch time, files (not folders) created by GDAA are not showing in the Web Drive interface anymore. A few showed up with a considerable delay (3+ hours) and nothing since. The Android GDAA find/search facility shows both the files (including contents) and folders, but the Web Drive has only folders. I use this code to test it, but I've tried the official demo as well with the same result.
回答1:
Fixed by emptying the Google Play Services cache using standard Android device
Settings -> Apps -> Google Play Services -> Clear Cache
probably a snag caused by a development environment abuse of the services. Will investigate further if it reappears.
... continued
As I was digging deeper, I have discovered a quirk that looks like a non-issue, but can create a big problem for app developers.
1/ lets assume that user can go to device's
Settings -> Apps -> Google Play Services -> Manage Space -> Clear All Data
anytime she/he decides to. The app that uses GDAA has no knowledge of this action, and the device owner has no idea that Google Play Services has anything to do with Google Drive based app.
2/ The moment this happens the GDAA app loses it's ability to find folders / files by TITLE. Queries fail here (see "NO md AVAILABLE")
...
if (rslt.getStatus().isSuccess()) {
MetadataBuffer mdb = null;
try {
mdb = rslt.getMetadataBuffer();
if (mdb == null) return null;
dMDs = new ArrayList<DrvMD>();
for (Metadata md : mdb) {
if ((md == null) || (!md.isDataValid()) || (md.isTrashed())) continue;
// NO md AVAILABLE !!!
}
} finally { if (mdb != null) mdb.close(); }
}
Even though it looks like a minor quirk, the fact that user can do this freely, causes MAJOR problem to the apps.
Here's why: Creating a folder/file in Google Drive will NOT fail if one with the same name exists. It will create a new one with the same name (and I understand the model). But if there is no reliable way to query for existence by name (caused by the user's action above), the app fails in this logic:
if (FOLDER/FILE by name exists)
return FOLDER/FILE ID
else
ID = create a new FOLDER/FILE
And so far this is the only logic I can come up when creating/accessing folder/file. I know there are 2 more unique IDs available (resource ID and DriveId), but they are not useful in this situation. Any ideas how to get around this? It would be nice if Google Play Services recovered from user's action without losing it's ability to query existing objects.
来源:https://stackoverflow.com/questions/22382099/files-created-by-the-new-google-drive-android-api-gdaa-not-showing-up