0

I am implementing audio manager widget application. I would like to use the following code.

this.getSystemService(Context.AUDIO_SERVICE)

but I can not use because I extend AppWidgetProvider class(not Activity class).

How should I change my coding? Thanks.

Nikhil
  • 16,194
  • 20
  • 64
  • 81
KMH
  • 61
  • 1
  • 1
  • 4

2 Answers2

1

All of the public methods that you can override in AppWidgetProvider will receive a Context that the provider is running within. Through that context you should be able to get the system service:

audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
Michael
  • 57,169
  • 9
  • 80
  • 125
0

I don't know the exact answer but in my case thee following link helped me:Sound pool and Service

Community
  • 1
  • 1
Rohit
  • 490
  • 3
  • 15