2013-05-09 151 views
0

大家好我是新手,但我不在乎你是否喜欢它......但我不明白这个网站的工作方式..... ............Android日历提醒事件问题

如果我问任何已经问过我的问题,我会得到负面的.....幸运的是,如果我找到有用的东西..问题是..然后..我不能添加我的评论这一职务澄清我的答案......比如我发现下面的链接有用我

Put reminder in real calendar on the phone?

在该代码的用户已经使用了下面的行

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

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

getCalendarUriBase(活性度ACT)

我就不会问这个问题,如果我已经允许添加我的意见成后

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

+0

getCalendarUriBase(Activity act)你检查了链接中的代码吗?有以活动上下文为参数的方法。因此,getCalendarUriBase(this) – Raghunandan 2013-05-09 17:55:31

回答

0

很奇怪,你不明白这个答案。

getCalendarUriBase返回一个字符串,其实现在该答案中。

我这里copypaste为你

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; 
+0

你能帮我这个声明....(epoch = new java.text.SimpleDateFormat(“yyyy-MM-dd hh:mm a”)。parse(date +“”+ time)。 getTime();)...我应该如何使用日期和时间?因为我有5个值(日,月,年,小时和分钟)所有int如何使用这5个int值而不是日期和时间在声明中提到? – Amjad 2013-05-09 18:40:51

0

恕我直言,

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

字符串连接?