问题描述
的程序功能是这样的:用户有电话号码,为此,蜂窝电话可以振动呼入时的列表只在没有其他系统级应用程序将提供的振动(如在静音模式)。我知道,这是某种违反规定的,对于一个应用程序应该尊重用户的设置,但应用程序仅限于一定的用户这方面的需求。我已经尝试了两种方式,但他们都不是令人满意的:
The program functions like this: the user has a list of phone numbers, for which the cellphone could vibrate upon an incoming call only when no other system-wide application would provide vibration (such as in mute mode). I know that this is somehow against the rules, for that an application should respect the users' settings, but the application is limited to some certain users with this need. I have tried two ways but neither of them are satisfying:
-
听电话的状态,并直接与我自己的模式引发的振动服务(与
Vibrator.vibrate()
)。这种方法是有效的,没有来电还随机有效的,当手机处于CALL_STATE_RINGING
状态,我想这是因为在实际处理振动系统广泛应用的冲突在来电。
Listen to the telephony state and directly trigger the vibration service with my own pattern (with
Vibrator.vibrate()
). This method is effective with no incoming calls yet randomly effective when the phone is inCALL_STATE_RINGING
state and I guess it's because of the conflict with the system-wide application that actually handles the vibration upon incoming call.
法官的手机是否振动来电(与 AudioManager.shouldVibrate()
)时,并决定是否改变震动设置(与 AudioManager.setRingerMode()
和 AudioManager.setVibrateSetting()
)。如果震动设置是由我的应用程序改变,他们将被恢复,一旦手机是回 CALL_STATE_IDLE
状态。这种方法,但是,仍然不能正常运行,有时,无原因的任何迹象。
Judge whether the cellphone is vibrating upon an incoming call (with AudioManager.shouldVibrate()
), and decide whether to change the vibrate settings (with AudioManager.setRingerMode()
and AudioManager.setVibrateSetting()
). If the vibrate settings are changed by my application, they are to be restored once the cellphone is back to CALL_STATE_IDLE
state. This method, however, is still not functioning sometimes, without any sign of the reason.
我希望有人能够给这个问题的一些建议。在这两种方式或其他建议意见,欢迎选购。
I hope that someone could give some advice on this issue. Comments on these two ways or other suggest are welcome.
推荐答案
您需要,以便为您的手机震动了两个设置玩。第一个是一个需要通过使用AufioManager设置声音模式:
You need to play with two settings in order for your phone to vibrate. The first one is the sound mode which needs to be set by using AufioManager:
AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
audioManager.setRingerMode(targetSoundMode);
第二部分是不正确的记录,我相信这是缺少的一部分,你的code:
The second part is not properly documented and I believe this is the missing part of your code:
String VIBRATE_IN_SILENT_SETTING_NAME = "vibrate_in_silent";
Settings.System.putInt(getContentResolver(), VIBRATE_IN_SILENT_SETTING_NAME, 1);
使用1开启震动,并0打开振动功能。
use 1 to turn vibrate on and 0 to turn vibrate off.
要充分了解你应该如何与震动设置工作和模式来看看下面的链接:http://hi-android.info/src/com/android/settings/SoundSettings.java.html
to fully understand how you should work with vibrate settings and mode take a look at the following link:http://hi-android.info/src/com/android/settings/SoundSettings.java.html
这篇关于如何提供特定的来电定制振动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!