Confusion regarding number of alarms needed to be

2019-07-15 18:33发布

问题:

I have the following data in SqlLite as well as Postgresql database and am successfully showing it in a tablularlayout on my android widget.It's basically a timetable for college students.

a http://www.4shared.com/download/1w7Tyicfce/random3.png

I did set OnClickListener for all the textviews individually,which means each and every subject name which you're seeing is clickable in my app.

Upon clicking on a subject name i.e a textview,a page shows up as following.

a http://www.4shared.com/download/Ii8DtkvJba/setalarm.png

Till now I have written code for setting up a single alarm only but not multiple.Hence selecting one checkbox only.However i am gonna set multiple alarms such that if one selects all the 4 checkboxes 4 alarms for a single subject must be triggering accordingly.

Question

1.While setting alarms for each subject individually,should i set 4 pendingintents for 4 checkbox selected time and only trigger those alarms which are selected in checkboxes?And should i use the same requestcode for the PendingIntent.getBroadcast or should i use 4 different requestcodes?Right now i have only 1 pendingintent.When save and set alarm button is clicked one alarm is being set according to the selected checkbox time.But i think this is not the right way for achieving the result.

2.I am assuming that i have to create 4 pendingintents for "one subject at one particular slot,for eg. for DBMS its monday 1:40-3:20PM,so 4 pendingintents for DBMS".Now in total do i need to create No. of subjects * 4 number of pendingintents each having differentrequestcodes?

Note

As it may be a little confusing please comment below if something is not clear in my question.

回答1:

The simple and short answer is The number of alarms for different time slots needed,the same number of pendingintents are needed to be created.