0
我想设置一个报警,在几分钟内重复编辑文本,但它似乎只是当它想要工作。编辑文本设置重复报警
public void startAlert(View view) {
EditText text = (EditText) findViewById(R.id.time);
int i = Integer.parseInt(text.getText().toString());
try {
Intent myIntent = new Intent(this, NotifyService.class);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
pendingintrent = PendingIntent.getService(this.getApplicationContext(),
12345, myIntent, 0);
alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(),
i * 60 * 60 , pendingintrent);
} catch (Exception e) {}
Toast.makeText(this, "Alarm set in " + i + " minutes",
Toast.LENGTH_LONG).show();
finish();
}
}