开发者

Want to upload a spreadsheet from an Android app to Google Docs - what is the best solution?

开发者 https://www.devze.com 2023-01-07 22:56 出处:网络
I\'d like to allow my Android app to upload a spreadsheet document to Google Docs. Using a simple Uri request:

I'd like to allow my Android app to upload a spreadsheet document to Google Docs. Using a simple Uri request:

Uri uri = Uri.parse("http://docs.google.com/DocAction?action=updoc&hl=en");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

and this page appears as blank on a phone (must use code not compatible with phones).

I've looked into the Google Docs procedures for uploading from a Web Service. They require first authenticating the user and retrieving an AuthSub authorization to be used in a following POST request (including the AuthSub token) to actually upload the doc. This is easy from a Web Service that can guarantee a URL to return the AuthSub to, but how about on a mobile phone?

Currently thinking that I'll use UrlConnection, use getHeader(String) to grab the AuthSub, then build the entire document dynamically like this:

POST /feeds/default/private/full HTTP/1.1
Host: docs.google.com
GData-Version: 3.0
Authorization: <your authorization header here>
Content-Length: 73612
Slug: test.xls
Content-Type: application/vnd.ms-excel

<?xml version='1.0' encoding='UTF-8'?>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="4" ss:ExpandedRowCount="4" x:FullColumns="1" x:FullRows="1">
<Row>
<Cell><Data ss:Type="String">IN</Data></Cell>
<Cell><Data ss:Type="String">OUT</Data></Cell>
<Cell><Data ss:Type="String">TIME</Data></Cell>
<Cell><Data ss:Type="String">SUBTOTAL</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">Value</Data></Cell>
<Cell><Data ss:Type="Number">123</Data></Cell>
<Cell><Data ss:Type="String">Example</Data></Cell>
<Cell><Data ss:Type="String">Example&l开发者_如何学编程t;/Data></Cell>
</Row>
</Table>
</Worksheet>

Anyone with any experience or suggestions - would love to hear a comment.

Thanks,

Rusty


Found all the info necessary in Google Docs documentation.

http://code.google.com/apis/documents/docs/3.0/developers_guide_java.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号