Android: Make phone call from service

Viewed 5157

I try to make a phone call from inside a service. The code I use is:

Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + number));
startActivity(intent);

and it works well from inside the main activity, but not from the service. The error occurs on the last line. Is it not possible to make a call inside a service?

And how could I make this piece of code run on the main activity?

2 Answers
Related