有没有一种方法来访问日历的条目,而无需使用gdata的Java的客户端?

编程入门 行业动态 更新时间:2024-10-24 19:23:31
本文介绍了有没有一种方法来访问日历的条目,而无需使用gdata的Java的客户端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否有可能从手机离线获得日历的条目?它似乎是唯一的方法是使用 gdata的Java的客户端

Is it possible to get the calendar's entries from the phone offline? It seem the only way is to use gdata-java-client.

推荐答案

这些回答都不错,但他们都涉及到硬编码日历URI (我已经可见在不同的Andr​​oid设备三种不同的化身)。

These answers are good, but they all involve hard-coding the Calendar URI (which I've seen in three different incarnations across different Android devices).

一个更好的方式来获取 URI (其中硬codeS一类的名称和场代替)会是这样的:

A better way to get that URI (which hard-codes the name of a class and a field instead) would be something like this:

Class<?> calendarProviderClass = Class.forName("android.provider.Calendar"); Field uriField = calendarProviderClass.getField("CONTENT_URI"); Uri calendarUri = (Uri) uriField.get(null);

这是不完美的(这将打破,如果他们曾经删除 android.provider.Calendar 类或 CONTENT_URI 字段),但它的工作原理上比任何单一的URI硬code更多的平台。

This isn't perfect (it will break if they ever remove the android.provider.Calendar class or the CONTENT_URI field) but it works on more platforms than any single URI hard-code.

请注意,这些反射方法将抛出例外这将需要被捕获或者再抛出调用方法。

Note that these reflection methods will throw exceptions which will need to be caught or re-thrown by the calling method.

更多推荐

有没有一种方法来访问日历的条目,而无需使用gdata的Java的客户端?

本文发布于:2023-10-27 23:35:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1534860.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:条目   方法来   客户端   日历   gdata

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!