由网友(自捅千刀)分享简介:ICS和JB有一个操作系统设置:上时振动环。我想接下来的code尝试获取状态,但值是不一样的。有没有广播或其他方式,我可以用? ICS and JB has a OS setting: "Vibrate on ring". I tried next code try to get the status, but t...
ICS和JB有一个操作系统设置:上时振动环。我想接下来的code尝试获取状态,但值是不一样的。有没有广播或其他方式,我可以用?
ICS and JB has a OS setting: "Vibrate on ring". I tried next code try to get the status, but the values are not the same. Is there Broadcast or other method I could use?
AudioManager audioManager = (AudioManager) this.getApplicationContext()
.getSystemService(Context.AUDIO_SERVICE);
boolean bVibrateRing = audioManager
.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER);
在ICS音效模式,当检查时振动环,这将是真实的。 但是,在JB这将是错误的。
In ICS Sound mode and when check the "Vibrate on ring", it will be true. But in JB it will be false.
我试过广播是这样的:
receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
if (extras != null) {
int nstate = extras
.getInt(AudioManager.EXTRA_RINGER_MODE);
Log.d("receiver", " receiver EXTRA_RINGER_MODE : "
+ nstate);
}
}
};
IntentFilter filter = new IntentFilter(
AudioManager.RINGER_MODE_CHANGED_ACTION);
registerReceiver(receiver, filter);
我只能得到一个方式的变化:
I could only get next mode change:
RINGER_MODE_NORMAL
RINGER_MODE_SILENT
RINGER_MODE_VIBRATE
有没有关于对时振动环的信息。
There is no information about "Vibrate on ring".
感谢您的任何提示和时间。
Thank you for your any hint and time.
推荐答案
下一步code可以检查状态:
Next code could check the status:
Settings.System.getInt(this.getApplicationContext().getContentResolver(),
"vibrate_when_ringing", 0);
相关推荐
最新文章