I am using the following code to create an instance of AudioManager
:
AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
mgr.setStreamMute(AudioManager.STREAM_SYSTEM, true);
while compiling i get an error saying:
Cannot find symbol : method getSystemService(java.lang.String)
AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
I also tried using :
AudioManager mgr = (AudioManager)Context.getSystemService(Context.AUDIO_SERVICE);
and I got the error:
non-static method getSystemService(java.lang.String) cannot be referenced from a static context
Which is the correct way of using the class and how can I avoid the above errors!