I want to make an app that you can select a certain day of the week using a switch and in that day the user receive a notification.
I read some posts here about it but after the channels update I'm not sure if they work.
I am kind of stuck so I don't have a lot of code yet:
public class MainActivity extends AppCompatActivity {
Switch segSwitch;
Switch terSwitch;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
segSwitch = findViewById(R.id.switch1);
terSwitch = findViewById(R.id.switch2);
Calendar calendar = Calendar.getInstance();
int day = calendar.get(Calendar.DAY_OF_WEEK);
switch (day) {
case Calendar.MONDAY:
notificate(segSwitch);
case Calendar.TUESDAY:
notificate(terSwitch);
}
}
public void notificate(View view) {
Switch mySwitch = (Switch) view;
if (mySwitch.isChecked())
{
Toast.makeText(this, "Time to put the garbage out!", Toast.LENGTH_LONG).show();
}
}
}