web-gelistirme-sc.com

Sessiz mod, programlı olarak android olarak kapatılabilir mi?

Android'de sessiz modu programlı olarak kapatmak mümkün mü?

25
whiteberryapps

Sizin için çözüm.

AudioManager am;
am= (AudioManager) getBaseContext().getSystemService(Context.AUDIO_SERVICE);

//For Normal mode
am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);

//For Silent mode
am.setRingerMode(AudioManager.RINGER_MODE_SILENT);

//For Vibrate mode
am.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
63
Chirag
//SilentToNomal and NormalToSilent device Programatically
 final AudioManager mode = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
//Silent Mode Programatically
mode.setRingerMode(AudioManager.RINGER_MODE_SILENT);

//Normal Mode Programatically
  mode.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
8
patel

Çözüm:

AudioManager audio_mngr = (AudioManager) getBaseContext().getSystemService(Context.AUDIO_SERVICE);
audio_mngr .setRingerMode(AudioManager.RINGER_MODE_SILENT);
6
Paresh Mayani

Evet, programlı olarak sessiz modun kapatılması ve açılması mümkündür; kod aşağıdadır: 

AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);

sessiz modunu ayarlamak için:

audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);

Normal mod için:

audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
0
Arun kumar
int normal = 2;
int vibrate = 1;
int silent = 0;
int RingerMode;
public static AudioManager AUDIOMANAGER;

@Override
public void onCreate() {
    super.onCreate();

    AUDIOMANAGER= (AudioManager) getBaseContext().getSystemService(Context.AUDIO_SERVICE);
    if (AUDIOMANAGER.getRingerMode() == normal) {
                    AUDIOMANAGER.setRingerMode(AudioManager.RINGER_MODE_SILENT);
                    RingerMode = normal;
    } else if (AUDIOMANAGER.getRingerMode() == vibrate) {
                    AUDIOMANAGER.setRingerMode(AudioManager.RINGER_MODE_SILENT);
                    RingerMode = vibrate;
                }
    //And after do all your jobs..... you can return to previous mode:
                    AUDIOMANAGER.setRingerMode(RingerMode);

}
0
Iman Marashi