0
    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);
    }
}

在摘机状态下,即被叫方接听电话时,手机不振动。可能的原因是什么?

4

1 回答 1

1

原因可能是您没有将权限添加到 AndroidManifest。将以下内容添加到您的AndroidManifest.xml:

<uses-permission android:name="android.permission.VIBRATE" />

问候

于 2013-04-30T07:34:35.227 回答