마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

안드로이드 시간 지정 질문

0 추천
public void onBtnNoti1() {
        Intent intent = new Intent(this, MainActivity.class);
        PendingIntent pIntent = PendingIntent.getActivity(MainActivity.this, 0, intent, 0);
 
        Notification noti = new Notification.Builder(this)
            .setSmallIcon(R.drawable.ic_launcher)
            .setTicker("New Message1")
            .setContentTitle("Noti - Sound")
            .setContentText("Self Activity")
            .setWhen(System.currentTimeMillis())   // 이걸 현재시간 말고, 데이터 피커를 사용해서 미리 
            .setContentIntent(pIntent)                     날짜를 예약해서 그 시간에 알람이 울리게 하고 싶은데,                    .build();                                             가능한 방법일까요??            
        
        noti.defaults |= Notification.DEFAULT_SOUND;
        noti.flags |= Notification.FLAG_AUTO_CANCEL;
엑시지 (170 포인트) 님이 2015년 6월 3일 질문

2개의 답변

+1 추천

네 당연히 가능합니다. .setWhen에 들어가는 파라미터가 long millisSecond 일테니

데이터 피커로 넘어온 값을 Date 또는 Calendar 객체로 만든다음 getTimeInMillis() 로 값을 넣어주면 됩니다.

Gradler (109,780 포인트) 님이 2015년 6월 4일 답변
0 추천
쎄미 (162,410 포인트) 님이 2015년 6월 4일 답변
...