Since: API level 11
public class

NfcPolicy

extends Object
java.lang.Object
   ↳ com.samsung.android.knox.nfc.NfcPolicy

Class Overview

This class provides APIs to Near Field Communication (NFC) Settings capability.

Since
API level 11
MDM 5.0

Summary

Public Methods
boolean allowNFCStateChange(boolean allow)
API to allow or disallow the user to change NFC state (turn on or off).
boolean isNFCStarted()
API to check if NFC is On or Off on Device.
boolean isNFCStateChangeAllowed()
API to check if the state of NFC could be changed by user.
boolean startNFC(boolean start)
API to turn NFC on or off.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public boolean allowNFCStateChange (boolean allow)

Since: API level 11

API to allow or disallow the user to change NFC state (turn on or off).

Parameters
allow true to allow NFC change, false to disallow
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to allow or disallow the user to change the NFC state. If set to false (disable), the user will not be able to change NFC state. The S-Beam feature which depend on this policy will not be affected by this setting. This feature does not change the current state of the NFC Adapter. To change NFC state, check startNFC(boolean).


 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 NFcPolicy nfcPolicy = edm.getNfcPolicy();

 try {

     boolean result = nfcPolicy.allowNFCStateChange(true);

     if (true == result) {

         // NFC state change is not allowed by user.

     }

 } catch (SecurityException e) {

     Log.w(TAG, "SecurityException: " + e);

 }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_HW_CONTROL" permission with a protection level of signature.
Since
API level 11
MDM 5.0
Multiuser Environment
Global Scope

public boolean isNFCStarted ()

Since: API level 11

API to check if NFC is On or Off on Device.

Returns
  • true if NFC is ON, false if NFC is OFF
Usage
An administrator can use this API to check if NFC is turned On or Off.


 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 NFcPolicy nfcPolicy = edm.getNfcPolicy();

 try {

     boolean result = nfcPolicy.isNFCStarted();

     if (true == result) {

         // NFC Adapter is ON.

     }

 } catch (SecurityException e) {

     Log.w(TAG, "SecurityException: " + e);

 }

 
Since
API level 11
MDM 5.0
Multiuser Environment
Global Scope

public boolean isNFCStateChangeAllowed ()

Since: API level 11

API to check if the state of NFC could be changed by user.

Returns
  • true if is allowed change state, false otherwise.
Usage
An administrator can use this API to check the user is allowed or not to change the NFC State(ON/OFF).


 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 NFcPolicy nfcPolicy = edm.getNfcPolicy();

 try {

     boolean result = nfcPolicy.isNFCStateChangeAllowed();

     if (true == result) {

         // NFC is state is allowed and can be enabled by user.

     }

 } catch (SecurityException e) {

     Log.w(TAG, "SecurityException: " + e);

 }

 
Since
API level 11
MDM 5.0
Multiuser Environment
Global Scope

public boolean startNFC (boolean start)

Since: API level 11

API to turn NFC on or off.

Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to turn NFC on or off. If set to false, NFC will be turned off. If set to true, NFC will be turned on. The S-Beam feature which depends on this policy will also be affected by this setting.


 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 NFcPolicy nfcPolicy = edm.getNfcPolicy();

 try {

     boolean result = nfcPolicy.startNFC(true);

     if (true == result) {

         // NFC adapter is turned on

     }

 } catch (SecurityException e) {

     Log.w(TAG, "SecurityException: " + e);

 }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_HW_CONTROL" permission with a protection level of signature.
Since
API level 11
MDM 5.0
Multiuser Environment
Global Scope