如何从Android中的不同帐户访问谷歌驱动器电子表格?

时间:2015-01-03 04:01:13

标签: google-sheets google-drive-api google-spreadsheet-api

我正在尝试访问用于登录用户的谷歌驱动器电子表格。我为它做了一个演示,但它只用于一个帐户使用谷歌驱动器API。我可以使用谷歌驱动器API登录用户?如果是,那么如何做到了吗?..请帮助我......提前致谢

public void Create_Spreadsheet(){

    DocsService docsService = new DocsService("MySampleApplication-v3");
    try {
        docsService.setUserCredentials("email",
                "password");
        URL GOOGLE_DRIVE_FEED_URL = new URL(
                "https://docs.google.com/feeds/default/private/full/");
        DocumentListEntry documentListEntry = new com.google.gdata.data.docs.SpreadsheetEntry();
        documentListEntry.setTitle(new PlainTextConstruct(
                et_en.getText().toString()));
        documentListEntry = docsService.insert(GOOGLE_DRIVE_FEED_URL,
                documentListEntry);


    } catch (AuthenticationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ServiceException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

As shown above..I made a demo for create spreadsheet .but its only for my account.

And in AndroidManifest.....

<meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

<meta-data
            android:name="com.google.android.apps.drive.APP_ID"
            android:value="API-KEY" />

0 个答案:

没有答案