2014-05-01 3 views
1

일부 토글 버튼 (총 5 개)이있는 목록보기가 있습니다 응용 프로그램의 기능은 사용자가 클릭 한 날짜에 대해 alrms를 설정하는 것입니다 토글 버튼을 선택했습니다 나는 데이터를 보내고 데이터를 가져올 수 있지만 다음에해야할 일을 알지 못했습니다. 단일 버튼에 대해 알람 울림을 할 수 있지만 알지 못합니다 여러 날짜로 설정하는 방법 사용자가 알람을 삭제할 수 있습니다 여기 나는 pIndex 목록보기에서 버튼의 인덱스 코드 을 걸었습니다 당신은 사람으로 설정할 수 있습니다어떻게 여러 개의 알람을 안드로이드에 설정할 수 있습니까

Intent intent = new Intent(); 
           intent.setAction("action_d"); 
           intent.putExtra("day",day); 
           intent.putExtra("month",month); 
           intent.putExtra("state",state); 
           intent.putExtra("count",mCount); 
           Log.v("pending intent",""+pIndex); 
           PendingIntent pendingIntent = PendingIntent.getBroadcast(context, pIndex, intent, 1); 
           AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); 
               alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),pendingIntent); 


    //on reciving class 
    final String action = arg1.getAction(); 
    if ("action_d".equals(action)) { 
      // do function d 

       String day = arg1.getExtras().getString("day"); 
       int cmonth =arg1.getExtras().getInt("month"); 
       int state =arg1.getExtras().getInt("state"); 
       int count =arg1.getExtras().getInt("count"); 

       if(cmonth == month){ 
        Log.v("setting alarm for ","action d recived"+day); 
       if(day.equals(cDate)) 
        { 

        vibrator.vibrate(2000); 
         notification.setLatestEventInfo(arg0, contentTitle, contentText, contentIntent); 
         //notification.defaults |= Notification.DEFAULT_SOUND; 
         notofManager.notify(NOTIF_ID,notification); 

         Intent mIntent = new Intent(arg0,DialogActivity.class); //Same as above two lines 
           mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
           arg0.startActivity(mIntent); 
        } 
       } 



     } 

답변

2

y 알람을 원하는대로 설정할 수 있습니다. AlarmManager에 전달하는 각 PendingIntent이 고유해야합니다. 불행히도 PendingIntent의 고유성을 결정할 때 Intent의 "추가 정보"는 무시됩니다. 따라서 각 PendingIntent의 고유성을 보장하기 위해 또는 고유 한 ACTION을 Intent에 제공해야합니다.

관련 문제