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,026
  • 20
  • 63
  • 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
  • 55,116
  • 9
  • 74
  • 120
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
  • 510
  • 3
  • 15