AnSan
AnSan

Reputation: 11

Android audio manager method causing a force close

New to this and a bit confused as to why calling the following method creates a force close:

AudioManager myaudiomanager;

public void toggleSilent()
{
  myaudiomanager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
}

I don't see any blatant errors and I have added permissions to the manifest regarding the audio manager.

Anyone able to direct me further?

Upvotes: 1

Views: 479

Answers (2)

Anthony Graglia
Anthony Graglia

Reputation: 5435

The object is never created first of all. Try that.

myaudiomanager = new AudioManager();
// Not sure what parameters are needed but the documentation in the audiomanager tag has it.

Upvotes: 1

gew
gew

Reputation: 9

If you posted the ADB log that might help..

A force close usually means your main thread is not responding, or more specifically not withing the alotted time of Android. I find it hard to believe a call into the AudioManager is causing a FC..

Upvotes: 0

Related Questions