如何打开谷歌驱动器,并选择在Android设备上的文件 [英] How to open Google drive and pick file in android device

查看:356
本文介绍了如何打开谷歌驱动器,并选择在Android设备上的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用程序有按钮调上传每当我点击它需要重定向到谷歌驱动器的按钮,从我必须选择一个文件和放大器;需要读取的文件(文件可能是CSV),

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),

反正是有做? 我试图跌破code,但它显示了客户端必须连接错误

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();
            }

在此先感谢

推荐答案

ACTION_PICK会做的伎俩。

ACTION_PICK will do the trick.

例如,如果你是来接接触,

For example if you were to pick contacts,

意向意图=新的意图(Intent.ACTION_PICK,ContactsContract.Contacts.CONTENT_URI);

Intent intent = new Intent(Intent.ACTION_PICK,ContactsContract.Contacts.CONTENT_URI);

会列出从驱动通讯录,通讯录等。

would list your contacts from Drive,Phone Book etc.

这篇关于如何打开谷歌驱动器,并选择在Android设备上的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆