2012-12-16 4 views
3

사용자가 단추를 눌렀을 때 호출하는 show_notification()이라는 함수가 있습니다. 요점은 [아래 함수에서와 같이] 클릭 한 번으로 알림을 표시하는 것입니다. 특정 알림에이 알림을 표시하고 싶습니다. time= hours:mins
시간과 분은 원하는 시간 값을 갖는 두 개의 정수입니다 [예 : 시간 = 22, 분 = 40 .. 22:40 [10:40 pm]에이 알림을 발합니다. 그런데이 알람은 매일 같은 시간에 반복되어야합니다.android : 특정 시간에 알림을 표시 하시겠습니까?

public void show_notification() { 
     CharSequence notify_msg="Don't foget!"; 
     CharSequence title= "you ve been notified by My app"; 
     CharSequence details= "It works!"; 
     NotificationManager nm= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
     Notification notify= new Notification(android.R.drawable.stat_notify_more, 
           notify_msg, 
           System.currentTimeMillis()); 
     Context mycontext= ActA.this; 
     Intent myintent= new Intent (mycontext, ActA.class); 
     PendingIntent pending= PendingIntent.getActivity(mycontext, 0, myintent, 0); ///0's are not applicable here 
     notify.setLatestEventInfo(mycontext, title, details, pending); 

     nm.notify(0, notify); 



    } 

저는 아주 새로운 개발자이므로 자세한 내용을 알려주십시오.

답변

7

매우 간단합니다. 알람 관리자를 사용할 수 있습니다. alarmmanager에서 알림을 얻으려면 매니페스트 파일을 수정하고 응용 프로그램을 등록해야 할 수 있습니다. 이제 알람 관리자 클래스에 응용 프로그램이 수신 할 원하는 시간에 메시지를 보내도록 요청할 수 있습니다.

이 메시지에 응답하고 사용자에게 알림을 표시하는 방식으로 활동을 프로그래밍해야합니다.

+0

자습서 나 예제에 대한 링크가 있습니까? 감사합니다 :) – CSawy

+4

http://android-er.blogspot.in/2010/10/simple-example-of-alarm-service-using.html - 알림으로 토스트를 바꿀 수 있습니다 –

+0

몇 가지 흥미로운 예가 있습니다. 이 페이지에서 알람 관리자로 할 수있는 흥미로운 것들. –

관련 문제