0

I'm trying to change status of my phone. Way I try to do this is like this:

AudioManager am;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_schedule);
    init();
}

private void init(){
am = (AudioManager) getBaseContext().getSystemService(Context.AUDIO_SERVICE);
}

public void onClick(View arg0) {
    switch (arg0.getId()){
    case R.id.bAdd:
        if (Mode.getSelectedItem().toString().equals("Ring")){
            am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
        }
        break;
    }
}

There is an error in my program "RINGER_MODE_NORMAL cannot be resolved or is not a field" and I have no idea why, in every topic about AudioManager there is all working good and they are doing it the same way I do. I have no more ideas where to look for answer.

Jakub
  • 201
  • 3
  • 11

1 Answers1

0
private void init(){
 am = (AudioManager) getBaseContext().getSystemService(Context.AUDIO_SERVICE);
}

Try to use another context, like application context. Did you have android.permission.MODIFY_AUDIO_SETTINGS permission on your manifest?

jedi
  • 839
  • 12
  • 33