Reputation: 61
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
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
Reputation: 490
I don't know the exact answer but in my case thee following link helped me:Sound pool and Service
Upvotes: 0