2011-05-13 8 views
1

안녕하세요 저는 현재 다음 코드를 사용하여 안드로이드의 기본 캘린더에 일정을 추가하고 있습니다.캘린더에 알림 추가

Calendar cal = Calendar.getInstance();    
    Intent intent = new Intent(Intent.ACTION_EDIT); 
     intent.setType("vnd.android.cursor.item/event"); 
    intent.putExtra("beginTime", cal.getTimeInMillis()); 
    intent.putExtra("allDay", false); 
    intent.putExtra("rrule", "FREQ=DAILY"); 
    intent.putExtra("endTime", cal.getTimeInMillis()+60*60*1000); 
    intent.putExtra("title", "A Test Event from android app"); 
    intent.putExtra("description", "Who knows! this might work"); 
intent.putExtra("eventLocation", "Hope this time it works"); 
    intent.putExtra("hasAlarm", 1); 
    startActivity(intent); 

내 질문은 당신이 볼 수 있듯이 , 나는 "FREQ = DAILY"사용하고,하고, 유사 등, "FREQ = YEARLY"와 "FREQ = MONTHLY"같은 값이 있습니다. 사용할 수있는 다른 대안을 알고 싶습니다. 그래서 코드에 제공 할 수 있습니다.

답변

0

오. 이제 알았어. 위의 코드에이 코드를 추가해야했습니다. 코드 아래

 ContentResolver cr = getContentResolver(); 
    Uri REMINDERS_URI = Uri.parse(getCalendarUriBase(this) + "reminders"); 
    values = new ContentValues(); 
    values.put("event_id", Long.parseLong(event.getLastPathSegment())); 
    values.put("method", 1); 
    values.put("minutes", 5); 
    cr.insert(REMINDERS_URI, values); 
+0

이 추가 코드는 한 수단 무엇? 설명을 추가하십시오 p.s 1 년 전에 물어 보았습니다. :) \) – shareef

0

은 나를 위해 일한 :

//===========code to add event============================= 

          try { 
            Date mDate = sdf.parse(givenDateString); 

            long settime= mDate.getTime(); 

            ContentValues values = new ContentValues(); 
            values.put("calendar_id", 1); 
            values.put("title", "Daze Event"); 
            values.put("dtstart", settime); 
            values.put("dtend", settime+10000); 
            values.put("description", "daze event"); 
            values.put("hasAlarm", 1); 
            String timezone=TimeZone.getDefault().getID(); 
            values.put("eventTimezone", timezone); 
            Uri baseUri; 
            if (Build.VERSION.SDK_INT >= 8) { 

            baseUri = Uri.parse("content://com.android.calendar/events"); 
            } else { 
             baseUri = Uri.parse("content://calendar/events"); 
            } 
            Uri uri = getContentResolver().insert(Events.CONTENT_URI, values); 

            // getContentResolver().insert(baseUri, values); 
            long eventID = Long.parseLong(uri.getLastPathSegment()); 


//==========code to reminder set :================ 

             Uri REMINDERS_URI = Uri.parse("content://com.android.calendar/reminders"); 
             values = new ContentValues(); 
             values.put("event_id", Long.parseLong(uri.getLastPathSegment())); 
             values.put("method", 1); 
             values.put("minutes", 1); 
             getContentResolver().insert(REMINDERS_URI, values); 

            } catch (Exception e) { 
             Log.d("catch", ""); 
             // Toast.makeText(getApplicationContext(), "id=", 45).show(); 
               e.printStackTrace(); 
            } 
관련 문제