目前,我正在使用Google Drive Android API将我的Android应用数据存储到Google云端硬盘应用文件夹.
这是我在保存应用程序数据时正在做的事情
这是执行上述操作的代码.
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云端硬盘.我正在使用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();,但有以下异常.
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)