我怎么能检测出的Andr​​oid手机在静音模式是否编程 [英] how can I detect whether the android phone in Silent mode programatically

查看:97
本文介绍了我怎么能检测出的Andr​​oid手机在静音模式是否编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能给我一个code段,以确定手机是否处于静音模式或不。

我使用的是Android 1.5。我试图通过使用android.provider.Settings.ACTION_SOUND_SETTINGS。这是行不通的。

Can anyone provide me a code snippet to identify whether the phone is in Silent mode or not.

I am using Android 1.5. I tried by using "android.provider.Settings.ACTION_SOUND_SETTINGS". It is not working.

推荐答案

使用的<一个href="http://developer.android.com/intl/fr/reference/android/media/AudioManager.html#getRingerMode%28%29"><$c$c>getRingerMode()方法 AudioManager

Use the getRingerMode() method in AudioManager.

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

switch (am.getRingerMode()) {
    case AudioManager.RINGER_MODE_SILENT:
        Log.i("MyApp","Silent mode");
        break;
    case AudioManager.RINGER_MODE_VIBRATE:
        Log.i("MyApp","Vibrate mode");
        break;
    case AudioManager.RINGER_MODE_NORMAL:
        Log.i("MyApp","Normal mode");
        break;
}

这篇关于我怎么能检测出的Andr​​oid手机在静音模式是否编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆