将Google日历与我自己的Android日历应用同步 [英] Sync Google Calendar with my own Calendar app on Android

查看:301
本文介绍了将Google日历与我自己的Android日历应用同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,这几天我一直在进行大量搜索,现在我很困惑该怎么办.

尝试执行的操作:创建了自己的日历并显示日历"上的所有事件.我现在所有事件都保存在XML文件中,一切正常.现在,我将自己的日历应用与我的OWN谷歌日历帐户相关联,以从我自己的Google日历帐户中获取(只读)所有事件,因为我不想再使用XML文件了.当我以后要更新事件时,这不是一个好主意.我不希望用户必须输入用户名/密码才能连接Google日历.我想进行硬编码.

问题:我通过使用G-Data Google Api为iPhone做了类似的事情,它完全可以实现我想要的功能.但是,G-Data Google Api 与Android不兼容.然后我搜索并发现ppl建议改用Google_api_java_client.

这是链接允许用户输入用户名&在其中与Google日历帐户建立联系.密码.但是,这不是我想要的.我想在我的代码中对用户名和密码进行硬编码,但是他们使用的是OAuth,因此我无法对我的用户名/密码进行硬编码.我还通过此链接尝试了ClientLogin,但它没有也不行.它总是使我出错"GoogleTransport无法解决"".我搜索了此错误的解决方案,ppl建议我回到OAuth.这真的让我感到困惑.

我希望有人对此有所了解并提出解决方案,请帮助我/指导我如何在android上实现此功能.我只想从我自己的Google日历帐户中读取数据,请不要从本地日历应用程序中读取数据.

我发现的最后信息是通过将经过身份验证的GET请求发送到allcalendars供稿解决方案

您已经正确使用了Android日历创建部分,现在您只需读取Google日历中的事件即可将其添加到新创建的Android日历中.

很简单.

  1. 通过 Google日历网络应用公开您的日历. (无论如何,将您的登录名/密码嵌入到您的应用程序中都是一个坏主意,任何人都可以窃取它).
  2. 在议程参数"页面上的公共日历URL 部分附近,您将能够复制公共 AgendaId (格式为xxxYYYzzz@group.calendar.google.com).
  3. 在您的应用中,对此URL进行http GET请求 https://developers.google.com/gdata/docs/2.0/reference#Queries

此外,请注意,这是旧的API.新的API需要您注册一个帐户才能使用它,并且每天最多只能有10000个免费请求.

Hello I'm stuck on this past few days with searching a lot, now I'm confusing what to do.

Trying to do: Created my own calendar and show all events on Calendar. I had all events in XML file for now, everything works fine. Now I'm connecting my calendar app with my OWN google calendar account to fetch (read only) all events from my own Google Calendar account because I dont want to use the XML file anymore. It's not a good idea when I want to update events later on. I dont want users have to enter username/pass to connect with Google Calendar. I would like to HARDCODED it.

Problems: I'm done something like this for iphone by using G-Data Google Api, it works exactly what I want to. However, G-Data Google Api is not compatible with Android. Then I searched and found ppl recommend use Google_api_java_client instead.

This is link where it can connect with a google Calendar account by letting user enter username& password. However, this is not I want. I want to hard coded username and password inside my code, but they are using OAuth then I can't hard coded my username/pass. I also tried ClientLogin from this link, but it doesn't work too. It keeps throw me error "GoogleTransport cannot be resolved". I searched solution for this error, ppl recommend me back to OAuth. This is really make me confusing now.

I hope someone experienced this and have solution, please help me/ guide me how to implement this on android. I just want to read data from my own google calendar account only, PLEASE not from native calendar app.

Last information that I found is by sending an authenticated GET request to the allcalendars feed URL. However, I never done this, if you think it should work, please assist me with that.

I really appreciated any helps. Thank you very much.

解决方案

You already got the Android calendar creation part right, you now only need to read events from your google calendar to add them to your newly created Android calendar.

It's easy.

  1. Make your calendar public from the Google calendar web app. (anyway embedding your login/pwd in your app is a bad idea, anyone could steal it).
  2. On the "agenda parameter" page, near the Public Calendar URL section, you will be able to copy the public AgendaId (in the form xxxYYYzzz@group.calendar.google.com).
  3. From your app, do an http GET request to this url https://www.google.com/calendar/feeds/AgendaId%40group.calendar.google.com/public/full?alt=json&orderby=starttime&max-results=15&singleevents=true&sortorder=ascending&futureevents=true (replace AgendaId by the real value) and you will be able to read future events in json format.
  4. To tweak the format (json/xml) or the number of returned entries, please read the documentation here: https://developers.google.com/gdata/docs/2.0/reference#Queries

Also, note this is the old API. The new API needs you to register an account to use it and is limited to 10 000 free requests per day.

这篇关于将Google日历与我自己的Android日历应用同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆