I am developing an App in which I need to block the teenager from using mobile while driving, I need to block the call and sms. please help . any small hints and clues will
To block outgoing calls, you need to register a PhoneStateListener
like:
telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.listen(new MyListener(), PhoneStateListener.LISTEN_CALL_STATE);
Then define your MyListener
class like:
private class Test extends PhoneStateListener {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
super.onCallStateChanged(state, incomingNumber);
switch(state)
{
case TelephonyManager.CALL_STATE_IDLE:
break;
case TelephonyManager.CALL_STATE_OFFHOOK://this case is for outgoing call
break;
case TelephonyManager.CALL_STATE_RINGING://this case is for incoming call
break;
default:
break;
}
}
}