I want to set two alarms in my app through intent.This is how the app should work, it should get time form the user and set alarm for that time +3 minutes.For instance, if the user wants to set an alarm for 8:30 it should set alarm for 8:30, and then for 8:33 immediately.I've used 3 as an example, but in the actual functioning, I will include a variable there.This app is to set multiple alarms with a gap that user enters. It will prompt the user about the number of such alarms to set.So I wrote two intents for it but only first one is working.This is my code:
Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM);
intent.putExtra(AlarmClock.EXTRA_MESSAGE, "Your alarm");
intent.putExtra(AlarmClock.EXTRA_HOUR, result);
intent.putExtra(AlarmClock.EXTRA_MINUTES, i);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
} else {
Toast.makeText(getApplicationContext(), "There is alarm option for your device", Toast.LENGTH_SHORT).show();
}
Intent intent1 = new Intent(AlarmClock.ACTION_SET_ALARM);
intent1.putExtra(AlarmClock.EXTRA_MESSAGE, "Your alarm");
intent1.putExtra(AlarmClock.EXTRA_HOUR, result);
intent1.putExtra(AlarmClock.EXTRA_MINUTES, i+3);
if (intent1.resolveActivity(getPackageManager()) != null) {
startActivity(intent1);
} else {
Toast.makeText(getApplicationContext(), "There is alarm option for your device", Toast.LENGTH_SHORT).show();
}
Can we make intent object as an array?
Thanks You for the help sir. Here is what I did.
@Override
public void onResume()
{ super.onResume();
secondintent();
}
public void secondintent() {
if (test == 1)
{
Intent intent1 = new Intent(AlarmClock.ACTION_SET_ALARM);
intent1.putExtra(AlarmClock.EXTRA_MESSAGE, mess);
intent1.putExtra(AlarmClock.EXTRA_HOUR, result);
intent1.putExtra(AlarmClock.EXTRA_MINUTES, i + 5);
startActivity(intent1);
i=i+5;
}