KMH
KMH

Reputation: 61

How do I implement AUDIO_SERVICE in widget

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.

Upvotes: 0

Views: 242

Answers (2)

Michael
Michael

Reputation: 58457

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);

Upvotes: 1

Rohit
Rohit

Reputation: 490

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

Upvotes: 0

Related Questions