How to allow incoming and outgoing calls only to specific call numbers
Environment
- Knox SDK
- Samsung Knox devices
Overview
This article provides information on how to allow incoming and outgoing calls to specific numbers and block incoming/outgoing calls to all other numbers using Knox SDK APIs.
To allow incoming and outgoing calls to specific numbers, you need to:
- Block incoming/outgoing calls for all numbers
- Allow specific numbers for incoming/outgoing calls
How do I block incoming/outgoing calls for all numbers?
Use Knox SDK’s setOutgoingCallRestriction and setIncomingCallRestriction APIs to block all incoming and outgoing calls, as specified below:
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
PhoneRestrictionPolicy phoneRestrictionPolicy = edm.getPhoneRestrictionPolicy();
try {
phoneRestrictionPolicy.setOutgoingCallRestriction("._");
phoneRestrictionPolicy.setIncomingCallRestriction("._");
} catch (SecurityException e) {
Log.w(TAG, "SecurityException: " + e);
}
How do I allow only specific numbers for incoming/outgoing calls?
Use addOutgoingCallExceptionPattern
and addIncomingCallExceptionPattern
to allow calls to specific numbers only, as shown below:
If the country code is +9
and mobile number that needs to be allowed for incoming and outgoing calls is 9999999999
, use the below code:
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance (context);
PhoneRestrictionPolicy phoneRestrictionPolicy = edm.getPhoneRestrictionPolicy();
try {
phoneRestrictionPolicy.setOutgoingCallRestriction ("._");
phoneRestrictionPolicy.addOutgoingCallExceptionPattern("\\+919999999999");
phoneRestrictionPolicy.setIncomingCallRestriction("._");
phoneRestrictionPolicy.addIncomingCallExceptionsPattern("\\+919999999999");
} catch (SecurityException e) {
Log.w(TAG, "SecurityException: " + e);
}
Additional information
To read more about the Knox SDK, please refer to the Knox SDK API reference.
Back to KBAsOn this page
Is this page helpful?