Add Weekly Event to Calendar

后端 未结 3 1786
时光说笑
时光说笑 2020-11-27 21:50

I would like to add an event to native Calendar, here i want to repeat this event on every Tuesday until 31 December 2015:

<         


        
3条回答
  •  不知归路
    2020-11-27 22:07

    Here I am sharing you a simple code hope that will help you or guide you:

    Intent intentAlarm = new Intent(getActivity(), AlarmReceiver.class);
    
    intentAlarm.putExtra("name", data.getName());
    intentAlarm.putExtra("desc", data.getDescription());
    intentAlarm.setData(Uri.parse("custom://" + data.getId()));
    intentAlarm.setAction(String.valueOf(data.getId()));
    
    // Create the AlarmManager
    AlarmManager alarmManager = (AlarmManager) getActivity()
            .getSystemService(Context.ALARM_SERVICE);
    
    // Set the alarm for a particular time
    alarmManager.set(AlarmManager.RTC_WAKEUP, Calendar_Object
            .getTimeInMillis(), PendingIntent.getBroadcast(
                        getActivity(), Integer.parseInt(data.getId()), intentAlarm,
                        PendingIntent.FLAG_UPDATE_CURRENT));
    

提交回复
热议问题