Android upload to GoogleDrive:类型视图的方法header2(字符串)未定义
我正在尝试使用可恢复的媒体上传将可恢复的媒体上传活动实施到GoogleDrive。。到目前为止,我在编译之前遇到的唯一错误是: 类型视图的方法header2(字符串)未定义 在我的FileUploadProgressListener类中。。我应该实现特定的布局还是使用当前的活动布局来添加此视图?无法获取有关它的任何信息Android upload to GoogleDrive:类型视图的方法header2(字符串)未定义,android,google-drive-api,Android,Google Drive Api,我正在尝试使用可恢复的媒体上传将可恢复的媒体上传活动实施到GoogleDrive。。到目前为止,我在编译之前遇到的唯一错误是: 类型视图的方法header2(字符串)未定义 在我的FileUploadProgressListener类中。。我应该实现特定的布局还是使用当前的活动布局来添加此视图?无法获取有关它的任何信息 import android.view.View; import com.google.api.client.googleapis.media.MediaHttpUploader
import android.view.View;
import com.google.api.client.googleapis.media.MediaHttpUploader;
import com.google.api.client.googleapis.media.MediaHttpUploaderProgressListener;
import java.io.IOException;
public class FileUploadProgressListener implements MediaHttpUploaderProgressListener {
@Override
public void progressChanged(MediaHttpUploader uploader) throws IOException {
switch (uploader.getUploadState()) {
case INITIATION_STARTED:
View.header2("Upload Initiation has started.");
break;
case INITIATION_COMPLETE:
View.header2("Upload Initiation is Complete.");
break;
case MEDIA_IN_PROGRESS:
View.header2("Upload is In Progress: " + uploader.getProgress());
break;
case MEDIA_COMPLETE:
View.header2("Upload is Complete!");
break;
}
}
}
到目前为止,我的上传方法如下,希望我尊重谷歌api java客户端示例标准
.... static variables previously defined
mDirectoryPath = Environment.getExternalStorageDirectory() + "/swimmer/swimlogs/";
java.io.File file = new java.io.File(mDirectoryPath + java.io.File.separator + mFileName);
mFileUri = Uri.fromFile(file);
.....
private static File uploadFile(boolean useDirectUpload) throws IOException {
java.io.File fileContent = new java.io.File(mFileUri.getPath());
Model.File fileMetadata = new File();
fileMetadata.setParents(Arrays.asList(new ParentReference().setId(mFolderId)));
fileMetadata.setTitle(fileContent.getName());
InputStreamContent mediaContent = new InputStreamContent("text/csv", new BufferedInputStream(new FileInputStream(fileContent)));
mediaContent.setLength(fileContent.length());
Drive.Files.Insert insert = mService.files().insert(fileMetadata, mediaContent);
MediaHttpUploader uploader = insert.getMediaHttpUploader();
uploader.setDirectUploadEnabled(useDirectUpload); // set to false
uploader.setChunkSize(MediaHttpUploader.MINIMUM_CHUNK_SIZE);
uploader.setProgressListener(new FileUploadProgressListener());
return insert.execute();
}
我将View.header2(字符串)更改为简单日志。。但我有个例外。。。。显示“Initiation has started!”后,似乎“Initiation is complete!don't pass…”如果我错过了任何重要参数,请不要通过?我输入了一个e.printStackTrace();语句,但我看不到跟踪和发生了什么…我最终使用处理程序转到DialogProgress模式…初始化MSService的方式很好