2013-05-09 149 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" 

字符串連接?