1)如何在AndroID App中同步Google Drive文件?
2)如何从已同步的电子表格中检索特定数据?
注意 – 我也对Google Docs API& Google Drive SDK.
在我的应用程序中使用什么?
我每次只有一个文件要同步,而不是所有文件.并且该文件通过私钥对所有人开放.
我已经实现了一些代码,但它不起作用.下面是我的电子表格公共网址,我想在我的AndroID应用程序中同步.
我正在遵循here的步骤.
My Test Spreadsheet URL
try { String USERname = "xxxxx"; String PASSWORD = "xxxxx"; SpreadsheetService service = new SpreadsheetService("Testing"); service.setUserCredentials(USERname,PASSWORD); // Todo: Authorize the service object for a specific user (see other sections) // define the URL to request. This should never change. URL SPREADSHEET_Feed_URL = new URL( "https://spreadsheets.Google.com/Feeds/spreadsheets/private/full"); // Make a request to the API and get all spreadsheets. SpreadsheetFeed Feed = service.getFeed(SPREADSHEET_Feed_URL,SpreadsheetFeed.class); List<SpreadsheetEntry> spreadsheets = Feed.getEntrIEs(); if (spreadsheets.size() == 0) { // Todo: There were no spreadsheets,act accordingly. } // Todo: Choose a spreadsheet more intelligently based on your // app's needs. SpreadsheetEntry spreadsheet = spreadsheets.get(0); System.out.println(spreadsheet.getTitle().getPlainText()); // Make a request to the API to fetch information about all // worksheets in the spreadsheet. List<WorksheetEntry> worksheets = spreadsheet.getWorksheets(); // Iterate through each worksheet in the spreadsheet. for (WorksheetEntry worksheet : worksheets) { // Get the worksheet's Title,row count,and column count. String Title = worksheet.getTitle().getPlainText(); int rowCount = worksheet.getRowCount(); int colCount = worksheet.getColCount(); // Print the fetched information to the screen for this worksheet. System.out.println("\t" + Title + "- rows:" + rowCount + " cols: " + colCount); }} catch (Exception e) { e.printstacktrace();}@H_301_4@解决方法 我知道了.我没有添加权限,这就是为什么它给我错误.我们需要在下面添加授权许可.
<uses-permission androID:name="androID.permission.ACCOUNT_MANAGER" /><uses-permission androID:name="androID.permission.AUTHENTICATE_ACCOUNTS" />@H_301_4@ @H_301_4@ @H_301_4@ @H_301_4@ 总结
以上是内存溢出为你收集整理的如何在Android应用中同步Google电子表格并从中读取行全部内容,希望文章能够帮你解决如何在Android应用中同步Google电子表格并从中读取行所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)