0

I'm trying to do an App to set a timer in my phone with an Intent but I don't know why it doesn't do anything when I tried to set the timer.

Here's my code:

public void setTimerClick(View view) {
    Intent i = new Intent(AlarmClock.ACTION_SET_TIMER);
    i.putExtra(AlarmClock.EXTRA_MESSAGE, descriptionAlarm.getText().toString());
    i.putExtra(AlarmClock.EXTRA_LENGTH, String.valueOf(timeTimer.getText().toString()));
    i.putExtra(AlarmClock.EXTRA_SKIP_UI, true);
    startActivityForResult(i, 1);
}

And there isn't any error message in the console.

What am I doing wrong?

HessianMad
  • 549
  • 7
  • 23
  • do you use permission SET_ALARM ? – Opiatefuchs Apr 13 '17 at 17:26
  • and why startActivityForResult? – Opiatefuchs Apr 13 '17 at 17:27
  • @Opiatefuchs yes I use the permission! – HessianMad Apr 13 '17 at 18:04
  • @Opiatefuchs I tried startActivity and startActivityForResult, the both. – HessianMad Apr 13 '17 at 18:05
  • what are you expecting? By the way `AlarmClock.EXTRA_SKIP_UI, true` doesn´t display an UI, so no AlarmClock starts visuell. If you are awaiting the clock app to start you have to set this to false. – Opiatefuchs Apr 13 '17 at 18:07
  • And, it´s just unlikely but possible, if your device doesn´t implement a system clock app that listens to `AlarmClock.ACTION_SET_TIMER` intent, nothing will happen..... – Opiatefuchs Apr 13 '17 at 18:09
  • @Opiatefuchs What I want is to set a timer in my phone via my App. To set a chronometer. – HessianMad Apr 13 '17 at 18:11
  • you should check if the intent can be handled: http://stackoverflow.com/questions/15407502/how-to-check-if-an-intent-can-be-handled-from-some-activity. If not, then it´s like I said, no clock app is listening to the intent and you can´t deal with that intent.. – Opiatefuchs Apr 13 '17 at 18:13
  • @Opiatefuchs I've checked if an intent can be handled from some activity and it seems to be handled from some activity... but anything is happening in my App hahaha. – HessianMad Apr 13 '17 at 18:20

0 Answers0