0

I've been trying to create an AlarmClock function in my app. I've read many tutorials but only a few do (but not exactly) what I need to do. In one of them, I found that using the AlarmClock class ACTION_SET_ALARM works, but using the default AlarmClock app in Android. I'm okay with it, as long as I can open my app after the user shuts down the ringing alarm. I found this: http://developer.android.com/reference/android/provider/AlarmClock.html#EXTRA_SKIP_UI

Is there a way to tell this alarm clock to open my app after ringing? If not, do you know any good tutorials that work for creating an AlarmClock function? Either using AlarmManager or any other method. Thanks!

EDIT: Here's a second explanation of what I want to do: I need to open the app after the alarm sounds, let's say that I set an alarm to 10:05 am. Android's default alarmclock app starts ringing at that hour and when I turn it off, my app opens.

Pablo Quemé
  • 1,144
  • 4
  • 12
  • 29

1 Answers1

0

You can, quite easily, launch another application from you own through the use of an Intent. Something like the following would work:

Intent newAppIntent;
PackageManager packageManager = getPackageManager();
newAppIntent = packageManager.getLaunchIntentForPackage("Name of app. you want to launch");
newAppIntent.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(newAppIntent);

This post provides more information on what you are trying to acomplish: Open another application from your own (intent)

Community
  • 1
  • 1
Willis
  • 5,128
  • 2
  • 28
  • 59
  • I need to open the app after the alarm sounds, let's say that I set an alarm to 10:05 am. Android's default alarmclock app starts ringing and when I turn it off, my app opens. – Pablo Quemé Jan 12 '15 at 17:45
  • This you cannot do; it would require modifying the source of the default Android alarm clock application. You have two options: 1. Download an alarm clock that will allow you to launch another application; "Alarm Clock Plus" would do the trick. 2. Write your own application. You could follow a tutorial for an alarm clock app and then simply add the code snippet mentioned in the answer above to launch a secondary application. Here is a good tutorial: http://www.steventrigg.com/alarm-manager-create-an-alarm-clock-in-android-tutorial-part-6/ – Willis Jan 12 '15 at 17:52
  • I supposed it couldn't be done... but thanks a lot for the tutorial! Gonna follow it, my original intention was to write the app but it has been quite a pain in the butt! – Pablo Quemé Jan 12 '15 at 17:56
  • Thank you a lot, the tutorial you provided really helped me out! – Pablo Quemé Jan 15 '15 at 22:00