大佬教程收集整理的这篇文章主要介绍了如何从android上传文件到谷歌驱动器,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我尝试了Google Play服务,但我没有找到任何上传/下载文件的方法.
我尝试使用Google Client库,但有些方法尚未解决.
如 :
service.files().insert(body,mediaContent).execute(); errors: The method execute() is undefined for the type Drive.Files.Insert
我可以通过以下代码上传图片,但这是Google Drive文件加载程序.我一次只能上传一个文件.
@H_519_13@mFile = new java.io.File(fileList.get(i)); Log.i(tag,"CreaTing new contents."); Drive.DriveApi.newContents(mGoogleApiClient).addResultCallBACk( new OnNewContentsCallBACk() { @Override public void onNewContents(ContentsResult result) { if (!result.getStatus().issuccess()) { Log.i(tag,"Failed to create new contents."); return; } Log.i(tag,"New contents created."); OutputStream outputStream = result .getContents().getOutputStream(); byte[] byteStream = new byte[(int) mFile .length()]; try { outputStream.write(byteStream); } catch (IOException e1) { Log.i(tag,"Unable to write file contents."); } MetadataChangeSet MetadataChangeSet = new MetadataChangeSet.builder() .setMimeType("image/jpeg") .setMimeType("text/html") .settitle("Android Photo.png").build(); // Create an intent for the file chooser,and // start it. IntentSender intentSender = Drive.DriveApi .newCreateFileActivityBuilder() .seTinitialMetadata(MetadataChangeSet) .seTinitialContents( result.getContents()) .build(mGoogleApiClient); try { mActivity.starTintentSenderForResult( intentSender,requEST_CODE_CREATOR,null,0); publishProgress(1); } catch (SendIntentexception E) { Log.i(tag,"Failed to launch file chooser."); publishProgress(0); } } });
但仍在争取下载文件.
以上是大佬教程为你收集整理的如何从android上传文件到谷歌驱动器全部内容,希望文章能够帮你解决如何从android上传文件到谷歌驱动器所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。