0
我可以在Google云端硬盘上创建文件,并在使用drive.google.com时自动为我设置语言。使用Google DRIVE API设置Google文档的默认语言
,但我有在创建通过我的应用程序中使用谷歌云端硬盘API文件的问题。(谷歌API服务驱动-V2-rev192-1.20.0.jar)
文档的默认语言是没有设置。 这是导致语音输入灰显的问题。
这是我在我的应用程序的CreateFile如何:
public static File createFile(Car car) {
System.out.println("CREATING FILE");
try {
File body = new File();
body.setTitle("Document for " + car.getCar_name()
+ ".docx");
body.setMimeType(GOOGLE_DOCOCUMENT_MIME_TYPE);
body.setEditable(true);
Permission ownership = getOwnerShipPermission();
Permission unlockedFile = getUnlockedFilePermission();
java.io.File fileContent = null;
fileContent = CarServiceReportTemplateFactory.createCarServiceReportTemplateFile(car);
FileContent mediaContent = new FileContent(MS_WORD_DOCUMENT_MIME_TYPE, fileContent);
File file = driveservice.files().insert(body, mediaContent).execute();
String fildid = file.getId();
driveservice.permissions().insert(fildid, unlockedFile).execute();
fileContent.delete();
return file;
} catch (IOException ex) {
ex.printStackTrace();
return null;
}
}
我也看看the drive api file category,但是我无法找到相关的设置默认语言的任何东西。
有趣的是,当我执行"Try it" simulator时,生成的文件在默认情况下似乎具有语言设置。 但是,当我在我的应用程序中尝试它时,语言不是默认设置的...因此语音输入变灰。 这是我曾尝试:
String timedTextLanguage = "English (United Kingdom)";
File file = driveservice.files().insert(body, mediaContent).setTimedTextLanguage(timedTextLanguage).execute();
我将非常感激,如果你知道一个解决此问题。
谢谢。
我注意到驱动器客户端jar文件有一个较新的版本。 难道这是? –
如果您检查Google Drive API的v2版本。唯一可以更改文件语言的选项是使用[Files:insert](https://developers.google.com/drive/v2/reference/files/insert)方法,此方法具有可选参数'timedTextLanguage '设置文本的语言。如果它可以帮助你,试试这个参数。有关更多信息,请检查此相关的[SO问题](http://stackoverflow.com/questions/12106138)。 – KENdi
嗨Kendi,谢谢你的帮助。 我没有运气试过timedTextlanguage。我基本上可以通过“英语”作为字符串参数吗? –