0

Possible Duplicate:
How to start an Activity from a Service?

apologies for my terminology in advance I am very new to android programming.

What i am trying to do:

i am trying to create an alarm clock application.

What i have so far:

so far i have a class that starts an alarm service after 5 seconds (this works fine). then when this service class starts i want it to start another class (called AlarmRinging) but this is where I come unstuck.

Any answers or avenues to check out would be greatly appreciated.

Community
  • 1
  • 1

1 Answers1

1

android.app.Service is descendant of android.app.Context so you can use startActivity directly. However since you start this outside any activity you need to set FLAG_ACTIVITY_NEW_TASK flag on the intent.

For example:

Intent i = new Intent();
i.setClass(this, MyActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);

where this is your service.

Kartik Domadiya
  • 29,868
  • 19
  • 93
  • 104