Я хочу установить напоминание на 12 p.M ежедневно, когда пользователь на коммутаторе. На isChecked()
мне setText
как «напоминают в 12: 00». Я хочу установить там будильник или напоминание. Код выглядит следующим образом :
private RadioButton radioButtonPlayback, radioButtonTranslate;
private TextView switchStatus;
private Switch mySwitch;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
switchStatus = (TextView) findViewById(R.id.switchStatus);
mySwitch = (Switch) findViewById(R.id.mySwitch);
//set the switch to ON
mySwitch.setChecked(true);
//attach a listener to check for changes in state
mySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
switchStatus.setText("Remind at: 12:00 PM");
} else {
switchStatus.setText("No reminders set");
}
}
});
//check the current state before we display the screen
if (mySwitch.isChecked()) {
switchStatus.setText("Remind at: 12:00 PM");
} else {
switchStatus.setText("No reminders set");
}
Попробовать это :
AlarmReceiverClass :
Класс AlarmService:
В менифесте :