Back to project page Silencer.
The source code is released under:
Apache License
If you think the Android project Silencer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.ch3d.silencer; /*from w ww . j a v a 2 s .co m*/ import android.content.Context; import android.content.Intent; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import com.ch3d.silencer.service.CallSilencerService; public class IncomingCallStateListener extends PhoneStateListener { private final Context mContext; private boolean isIncoming; public IncomingCallStateListener(final Context context) { mContext = context; } @Override public void onCallStateChanged(final int state, final String incomingNumber) { switch (state) { case TelephonyManager.CALL_STATE_RINGING: isIncoming = true; mContext.startService(new Intent(mContext, CallSilencerService.class)); break; case TelephonyManager.CALL_STATE_IDLE: case TelephonyManager.CALL_STATE_OFFHOOK: if (isIncoming) { mContext.stopService(new Intent(mContext, CallSilencerService.class)); isIncoming = false; } break; default: break; } } }