public void onCallStateChanged(int state, String incomingNumber) {
Log.i("CALL_STATE changed " ,"phoneState");
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
Log.i("IDLE","CALL_STATE_IDLE");
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
//This is where we know call is established
Vibrator mVibrator = (Vibrator) mcontext.getSystemService(mcontext.VIBRATOR_SERVICE);
// Vibrate for 250 milliseconds
mVibrator.vibrate(250);
break;
case TelephonyManager.CALL_STATE_RINGING:
Log.i("RINGING","CALL_STATE_RINGING");
break;
default:
Log.d("TAG", "Unknown phone state=" + state);
}
}
在OFFHOOK状态下,即当被叫方接听电话时,电话没有振动。可能的原因是什么?
答案 0 :(得分:1)
原因可能是您没有将权限添加到AndroidManifest。
将以下内容添加到您的AndroidManifest.xml
:
<uses-permission android:name="android.permission.VIBRATE" />
此致