[英]How to open Google drive and pick file in android device
In my android application have button called Upload whenever i click the button it needs to redirect to Google Drive, from that i have to pick a file & need read the file (file may be csv), 在我的Android应用程序中,每当我单击按钮需要重定向到Google云端硬盘时,都有一个名为上传的按钮,从中我必须选择一个文件并需要读取该文件(文件可能是csv),
is there anyway to do?? 反正有要做吗? I have tried below code but it shows Client must connected error
我试过下面的代码,但它显示客户端必须连接错误
GoogleApiClient mGoogleApiClient;
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Drive.API).addScope(Drive.SCOPE_FILE)
.addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).build();
mGoogleApiClient.connect();
// Launch user interface and allow user to select file
IntentSender i = Drive.DriveApi.newOpenFileActivityBuilder()
.setMimeType(new String[] { "text/plain" })
.build(mGoogleApiClient);
try {
startIntentSenderForResult(i, 100, null, 0, 0, 0);
} catch (SendIntentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Thanks in advance 提前致谢
ACTION_PICK will do the trick. ACTION_PICK将解决问题。
For example if you were to pick contacts, 例如,如果您要选择联系人,
Intent intent = new Intent(Intent.ACTION_PICK,ContactsContract.Contacts.CONTENT_URI); 意图意图=新意图(Intent.ACTION_PICK,ContactsContract.Contacts.CONTENT_URI);
would list your contacts from Drive,Phone Book etc. 会从云端硬盘,电话簿等列出您的联系人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.