android如何检测取消按钮点击连接到谷歌硬盘?

时间:2014-01-21 16:21:29

标签: android google-drive-api

当用户尝试连接到GoogleDrive进行下载时,会显示身份验证表单,w用户google帐户...当用户单击“确定”时工作正常,但如何捕获“取消”按钮单击以将意图发送给另一个活动......? 唯一的检查是“onItemClick”......

            // Connect to Google Drive, access to all files
        mCredential = GoogleAccountCredential.usingOAuth2(this, Arrays.asList(DriveScopes.DRIVE));
        startActivityForResult(mCredential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER);

        OnItemClickListener mMessageClickedHandler = new OnItemClickListener()  {
            public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
                downloadItemFromList(position);
                finish();
            }
        };

我试图捕获取消异常,但不接受

        try {
        mCredential = GoogleAccountCredential.usingOAuth2(this, Arrays.asList(DriveScopes.DRIVE));
    } catch (OperationCanceledException e) {
        e.printStackTrace();
        return;
    } catch (AuthenticatorException e) {
        e.printStackTrace();
        return;
    } catch (IOException e) {
        e.printStackTrace();
        return;
    }

我不确定哪个取消操作正在捕捉...

1 个答案:

答案 0 :(得分:0)

我应该处理onActivityResult {}的责任 该死的!为时已晚......停止为今天工作