Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android中未解析JsonHttpRequestInitializer()方法_Android_Json_Google Drive Api - Fatal编程技术网

android中未解析JsonHttpRequestInitializer()方法

android中未解析JsonHttpRequestInitializer()方法,android,json,google-drive-api,Android,Json,Google Drive Api,我在谷歌硬盘上工作。经过很长一段时间,我能够上传文件在谷歌驱动器在我的帐户。但当我试图从android应用程序访问Google drive帐户时,我无法下载文件,问题是以下方法没有得到解决 Drive.Builder b = new Drive.Builder(httpTransport, jsonFactory, null); b.setJsonHttpRequestInitializer(new JsonHttpRequestInitializer() {

我在谷歌硬盘上工作。经过很长一段时间,我能够上传文件在谷歌驱动器在我的帐户。但当我试图从android应用程序访问Google drive帐户时,我无法下载文件,问题是以下方法没有得到解决

Drive.Builder b = new Drive.Builder(httpTransport, jsonFactory, null);

b.setJsonHttpRequestInitializer(new JsonHttpRequestInitializer() {
                    @Override
                    public void initialize(JSonHttpRequest request) throws IOException {
                        DriveRequest driveRequest = (DriveRequest) request;
                        driveRequest.setPrettyPrint(true);
                        driveRequest.setKey("186535896147");
                        driveRequest.setOauthToken(token);
                    }
                });

在Android上,使用
GoogleAccountCredential
对象来授权请求,而不是像上面那样拦截请求

credential = GoogleAccountCredential.usingOAuth2(context, DriveScopes.DRIVE);
b = new Drive.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), credential).build();

完整流程已在上实现,请将其用作参考。

我无法正确使用。我的应用程序正在崩溃。如果不介意,请与我共享您的代码。