1

알람 시계 앱으로 작업하고 있습니다. 특정 지역을 클릭 할 때 알람을 활성화 및 비활성화하는 기능을 추가하고 싶습니다.이 모든 것은 listView에서 BaseAdapter으로 이루어져야합니다. 아래 코드와 적절한 시간에 내 BroadcastReceiver 트리거를 사용합니다. 그러나!!! 데이터를 의도에서 추가로 가져올 수 없습니다. 기본값을 추가로 얻습니다.인 텐트에서 추가 얻기 (BaseAdapter => BroadcastReceiver)

기능은 알람 설정 :

public void setAlarm(int dayOfWeek, int hour, int minute, int position, int y) { 
     // Add this day of the week line to your existing code 
     Log.e("Point_1","Position " + position); 
     Calendar calendar = Calendar.getInstance(); 

     Date previoudTime = calendar.getTime(); 
     calendar.set(Calendar.DAY_OF_WEEK, dayOfWeek); 

     calendar.set(Calendar.HOUR, hour); 
     calendar.set(Calendar.MINUTE, minute); 
     calendar.set(Calendar.SECOND, 0); 
     calendar.set(Calendar.MILLISECOND, 0); 
     AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); 
     Intent intent1 = new Intent(context, MyReceiver_Alarm.class); 
     intent1.putExtra("Size_ABC", y); 
     intent1.putExtra("key", position); 
     //Log.e("Point_1", "Compare1 " + calendar.getTime()); 
     Log.e("Point_1", "Compare2 " + previoudTime); 
     Log.e("Point_1", "Compare " + calendar.getTime().compareTo(previoudTime)); 
     if(calendar.getTime().compareTo(previoudTime) < 0) { 

      int a = calendar.get(Calendar.WEEK_OF_MONTH); 
      calendar.set(Calendar.WEEK_OF_MONTH,a + 1); 
      //Log.e("Point_1", "Less " + calendar.getTime()); 
     } 
     Long alarmTime = calendar.getTimeInMillis(); 

     PendingIntent pendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), position , intent1, 0); 
     //Also change the time to 24 hours. 
     alarmManager.setExact(AlarmManager.RTC_WAKEUP, alarmTime, pendingIntent); 
     Log.e("Point_1", "Time is " + calendar.getTime()); 
    } 

을 그리고 이것이 내가

Log.e("Point_1","Position_intent " + intent.getIntExtra("key",178989800)); 

맞춰 추가 얼마나, 내가 어떤 번호를? 그래, 맞아. 178989800. 제대로 작동시키는 법?

감사합니다. 대신

PendingIntent pendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), 
     position, intent1, 0); 

답변

1

PendingIntent pendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), 
     position, intent1, PendingIntent.FLAG_UPDATE_CURRENT); 

PendingIntent.FLAG_UPDATE_CURRENT이 "엑스트라"는 PendingIntent에 추가됩니다 보장 추가 할.