2011-05-13 4 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); 

제 질문은 캘린더에 알림을 추가 할 수 있도록이 코드를 편집 할 수 있습니까?

답변

1

포럼에서이 작업을 수행하는 방법에 대한 몇 가지 게시물이 있습니다. Google 코드에서 발견 된 일부 API를 사용하는 것을 포함하여 여러 가지 방법이 있지만 이전에 시도하지 않았지만 트리거되는 경고가 기본값을 기반으로한다는 의심이 들더라도 간단한 방법 인 것으로 나타났습니다. . 그러나 일부 탐험을 통해 사용자 정의 방법을 찾을 수 있어야합니다. 어떤 경우

, 여기에서 언급 한 바와 같이 : how to edit the calendar events via android application

당신은 ContentValues이 개체에 대한 일정 항목

ContentValues event = new ContentValues(); 

로 작동하는 객체를 사용해야합니다, 당신은이 방법으로 알람을 활성화 할 수 있습니다 :

event.put("hasAlarm", 1); // 0 for false, 1 for true 

게시물에는 경보 설정을 지정하는 방법이 나와 있지 않지만 사용자가 어떤 문자열 키를 사용할 수 있는지 조사하여 찾을 수 있습니다. se 메소드를 사용하여 Calendar Intent에 대해 ContentValues를 사용할 때

이 완료되면,이 방법으로 달력에 이벤트를 넣을 수 있습니다 :

Uri eventsUri = Uri.parse("content://calendar/events"); 
Uri url = getContentResolver().insert(eventsUri, event);