Birdun
Birdun

Reputation: 7

what should be inside the method getSystemService(context.audio_service) in android

I'm trying to run a program to set the phone to normal mode from silent mode but i dont know what should be inside the method getSystemService(Context.AUDIO_SERVICE)

i have this line of code:

final AudioManager mode = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);

mode.setRingerMode(AudioManager.RINGER_MODE_NORMAL);

but i think i need to declare or create a method getSystemService and i dont know what should be its content

thank you

Upvotes: 0

Views: 1122

Answers (1)

Bryan Dunlap
Bryan Dunlap

Reputation: 1156

You dont need to implementgetSystemService(), it is a method from the Context class.

this should refer to a Context instance. In this case, the code you copied likely came from an Activity class, which indirectly extends Context.

Upvotes: 1

Related Questions