相关疑难解决方法(0)

如何避免始终从Google云端硬盘加载缓存的应用数据

目前,我正在使用Google Drive Android API将我的Android应用数据存储到Google云端硬盘应用文件夹.

这是我在保存应用程序数据时正在做的事情

  1. 为当前本地zip文件生成校验和.
  2. Google云端硬盘应用文件夹中搜索,查看是否存在现有的应用文件夹zip文件.
  3. 如果有,用当前本地zip文件覆盖现有App Folder zip文件的内容.此外,我们将使用最新的校验和重命名现有的App Folder zip文件名.
  4. 如果没有现有的App Folder zip文件,请生成一个新的App Folder zip文件,其中包含本地zip文件的内容.我们将使用最新的校验和作为App Folder zip文件名.

这是执行上述操作的代码.

生成新的App Folder zip文件,或更新现有的App Folder zip文件

public static boolean saveToGoogleDrive(GoogleApiClient googleApiClient, File file, HandleStatusable h, PublishProgressable p) {
    // Should we new or replace?

    GoogleCloudFile googleCloudFile = searchFromGoogleDrive(googleApiClient, h, p);

    try {
        p.publishProgress(JStockApplication.instance().getString(R.string.uploading));

        final long checksum = org.yccheok.jstock.gui.Utils.getChecksum(file);
        final long date = new Date().getTime();
        final int version = org.yccheok.jstock.gui.Utils.getCloudFileVersionID();
        final String title = getGoogleDriveTitle(checksum, date, …
Run Code Online (Sandbox Code Playgroud)

android google-drive-api google-drive-android-api

58
推荐指数
1
解决办法
1783
查看次数

Google Drive API - 名称不得为空:null(但我已将有效的帐户名称传递给GoogleAccountCredential)

最近,我有Android代码访问Google云端硬盘.我正在使用Google API Client Library for Java而不是Google Play服务客户端库

private static GoogleCloudFile searchFromGoogleDrive(Drive drive, String qString, HandleUserRecoverableAuthIOExceptionable h, PublishProgressable p) {
    try {
        Files.List request = drive.files().list().setQ(qString);

        do {        
            if (p.isCancelled()) {
                return null;
            }

            FileList fileList = request.execute();
Run Code Online (Sandbox Code Playgroud)

如果我使用,代码可以在几年内完成100%罚款targetSdkVersion 21.

最近,我将我的应用迁移到targetSdkVersion 23了Google Drive相关代码的0更改.

但是,代码崩溃了FileList fileList = request.execute();,但有以下异常.

使用1.18.0-rc时出现错误日志

Process: org.yccheok.jstock.gui, PID: 30317
java.lang.RuntimeException: An error occurred while executing doInBackground()
    at android.os.AsyncTask$3.done(AsyncTask.java:309)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    at …
Run Code Online (Sandbox Code Playgroud)

android google-drive-api

12
推荐指数
2
解决办法
8452
查看次数