Back to top

How to allow incoming and outgoing SMS only to specific phone numbers


  • Knox SDK
  • Samsung Knox Devices


This article provides information on how to allow incoming and outgoing SMS to specific numbers and blocking incoming/outgoing SMS to all other numbers using Knox SDK APIs.

To allow incoming and outgoing SMS to specific numbers, you need to:

  1. Block incoming/outgoing SMS for all numbers.
  2. Allow specific numbers for incoming/outgoing SMS.

How do I block incoming/outgoing SMS to all numbers?

Use Knox SDK’s setOutgoingSmsRestriction and setIncomingSmsRestriction APIs to block all incoming and outgoing SMS as specified below:

EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
PhoneRestrictionPolicy phoneRestrictionPolicy = edm.getPhoneRestrictionPolicy();
try {
        phoneRestrictionPolicy.setOutgoingSmsRestriction ("._");
        phoneRestrictionPolicy.setIncomingSmsRestriction ("._");
    } catch (SecurityException e) {
        Log.w(TAG, "SecurityException: " + e);

How do I allow only specific numbers for incoming/outgoing SMS?

Use Knox SDK’s addOutgoingSmsExceptionPattern and addIncomingSmsExceptionPattern APIs to allow SMS to specific numbers only as specified below:

As an example, if the country code is “+91” and the mobile number that needs to be allowed for incoming and outgoing SMS is “9999999999”, use the following code:

EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance (context);
PhoneRestrictionPolicy phoneRestrictionPolicy = edm.getPhoneRestrictionPolicy();
try {
        phoneRestrictionPolicy. setOutgoingSmsRestriction ("._");
        phoneRestrictionPolicy. addOutgoingSmsExceptionPattern ("\\+919999999999");
        phoneRestrictionPolicy. setIncomingSmsRestriction ("._");
        phoneRestrictionPolicy. addIncomingSmsExceptionPattern ("\\+919999999999");
    } catch (SecurityException e) {
        Log.w(TAG, "SecurityException: " + e);

Additional information

To read more about Knox SDK, please refer Knox SDK API reference.

Back to KBAs

Is this page helpful?