0

大家好,我是这里的新手,但我不在乎你们是否喜欢............但我不明白这个网站的工作方式...... ……

如果我问任何已经被问过的问题,我会得到否定的分数......幸运的是,如果我发现一些有用的东西......问题是......我无法在该帖子中添加我的评论以澄清我的答案...例如,我发现以下链接对我有用

将提醒放在手机上的真实日历中?

在该代码中,用户使用了以下行

Uri EVENTS_URI = Uri.parse(getCalendarUriBase(this) + "events");

我不明白我应该怎么做,因为 Uri.parse() 接受一个字符串参数,但在这里他使用一个活动作为参数

getCalendarUriBase(活动行为)

如果我允许将我的评论添加到该帖子中,我就不会问这个问题

我希望你能理解我的观点......完整的代码请访问上面的链接

4

2 回答 2

0

奇怪的是你不明白那个答案。

getCalendarUriBase 返回一个字符串,它的实现在那个答案中。

我在这里为你复制粘贴

private String getCalendarUriBase(Activity act) {

                String calendarUriBase = null;
                Uri calendars = Uri.parse("content://calendar/calendars");
                Cursor managedCursor = null;
                try {
                    managedCursor = act.managedQuery(calendars, null, null, null, null);
                } catch (Exception e) {
                }
                if (managedCursor != null) {
                    calendarUriBase = "content://calendar/";
                } else {
                    calendars = Uri.parse("content://com.android.calendar/calendars");
                    try {
                        managedCursor = act.managedQuery(calendars, null, null, null, null);
                    } catch (Exception e) {
                    }
                    if (managedCursor != null) {
                        calendarUriBase = "content://com.android.calendar/";
                    }
                }
                return calendarUriBase;
于 2013-05-09T18:00:24.067 回答
0

恕我直言,

getCalendarUriBase(this) + "events"
=
getCalendarUriBase(this).toString() + "events"

字符串连接?

于 2013-05-09T18:06:03.633 回答