0

I was just looking at this example:

Silence Android Phone in Java

Can you silence a phone from within a Service running in the background, or do you need to pass a message to the Activity so that it can silence the phone?

Any help would be greatly appreciated, thanks!

Community
  • 1
  • 1
Gary O' Donoghue
  • 362
  • 2
  • 4
  • 15
  • If what I posted as an answer has answered your main question, please consider marking it as an answer. – A--C Dec 09 '12 at 17:53

1 Answers1

2

Service extends Context, so you do not have to use an Activity.

This is due to how Java works. For information on inheritance, see here.

For the Service API, see here.

A--C
  • 36,351
  • 10
  • 106
  • 92
  • cool thanks, im getting some error in my code...Unable to instantiate service com.example.reminderalarm.AlarmService: java.lang.NullPointerException and it only seems to pop up when i start using the AudioManager, without that the Service gets instantiated fine and runs away grand, any ideas why that would be? – Gary O' Donoghue Nov 27 '12 at 22:34
  • I'd make a new question and post all your relevant code **and** logcat. It's better than having two separate questions in one post. – A--C Nov 27 '12 at 22:36