Code example for TelephonyManager

Methods: getCallState

0
            mVibrationStartupLevel = sp.getInt(PreferenceKeys.Ringer.VIBRATOR_STARTUP_LEVEL, maxVolume);;
        } 
    } 
 
    private boolean isRinging() { 
        return mTelephonyManager.getCallState() == TelephonyManager.CALL_STATE_RINGING;
    } 
     
    @Override 
    protected boolean shouldStop() { 
        return !isRinging(); 
    } 
     
    private boolean isGlobalVibrateOn() { 
        AudioManager audioManager = (AudioManager) this.getSystemService(AUDIO_SERVICE);
        return audioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER) == AudioManager.VIBRATE_SETTING_ON;
        //return audioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER); 
    } 
     
    private void setVibration(boolean on) {
Connect your IDE to all the code out there  Get Codota for Java