Thursday, July 19, 2012

Toggle between ringing and silent ringing mode



Source Code :


 AudioManager vAudioManager;
    public void Toggle(View view){
    Button vButton=(Button)findViewById(R.id.button1);
    ImageView vImageView=(ImageView)findViewById(R.id.imageView1);
        vAudioManager=(AudioManager)getSystemService(AUDIO_SERVICE);
    if(vAudioManager.getRingerMode()==vAudioManager.RINGER_MODE_NORMAL){
        vButton.setText("Silent Mode");
    vImageView.setImageDrawable(getResources().getDrawable(R.drawable.phone_silent));
        vAudioManager.setRingerMode(vAudioManager.RINGER_MODE_SILENT);
    }
    else{
    vButton.setText("Ringing Mode");
    vImageView.setImageDrawable(getResources().getDrawable(R.drawable.phone_on));
        vAudioManager.setRingerMode(vAudioManager.RINGER_MODE_NORMAL);
    }
    }

No comments:

Post a Comment