Fields Summary |
---|
private static final String | TAG |
public static final String | ACTION_RF_FIELD_ON_DETECTEDBroadcast Action: an RF field ON has been detected.
This is an unreliable signal, and will be removed.
Requires the {@link android.Manifest.permission#WRITE_SECURE_SETTINGS} permission
to receive. |
public static final String | ACTION_RF_FIELD_OFF_DETECTEDBroadcast Action: an RF field OFF has been detected.
This is an unreliable signal, and will be removed.
Requires the {@link android.Manifest.permission#WRITE_SECURE_SETTINGS} permission
to receive. |
private static android.nfc.INfcAdapterExtras | sService |
private static final CardEmulationRoute | ROUTE_OFF |
private static final HashMap | sNfcExtras |
private final NfcExecutionEnvironment | mEmbeddedEe |
private final CardEmulationRoute | mRouteOnWhenScreenOn |
private final android.nfc.NfcAdapter | mAdapter |
final String | mPackageName |
Methods Summary |
---|
void | attemptDeadServiceRecovery(java.lang.Exception e)NFC service dead - attempt best effort recovery
Log.e(TAG, "NFC Adapter Extras dead - attempting to recover");
mAdapter.attemptDeadServiceRecovery(e);
initService(mAdapter);
|
public void | authenticate(byte[] token)Authenticate the client application.
Some implementations of NFC Adapter Extras may require applications
to authenticate with a token, before using other methods.
try {
sService.authenticate(mPackageName, token);
} catch (RemoteException e) {
attemptDeadServiceRecovery(e);
}
|
public static com.android.nfc_extras.NfcAdapterExtras | get(android.nfc.NfcAdapter adapter)Get the {@link NfcAdapterExtras} for the given {@link NfcAdapter}.
Requires the {@link android.Manifest.permission#WRITE_SECURE_SETTINGS} permission.
Context context = adapter.getContext();
if (context == null) {
throw new UnsupportedOperationException(
"You must pass a context to your NfcAdapter to use the NFC extras APIs");
}
synchronized (NfcAdapterExtras.class) {
if (sService == null) {
initService(adapter);
}
NfcAdapterExtras extras = sNfcExtras.get(adapter);
if (extras == null) {
extras = new NfcAdapterExtras(adapter);
sNfcExtras.put(adapter, extras);
}
return extras;
}
|
public com.android.nfc_extras.NfcAdapterExtras$CardEmulationRoute | getCardEmulationRoute()Get the routing state of this NFC EE.
Requires the {@link android.Manifest.permission#WRITE_SECURE_SETTINGS} permission.
try {
int route = sService.getCardEmulationRoute(mPackageName);
return route == CardEmulationRoute.ROUTE_OFF ?
ROUTE_OFF :
mRouteOnWhenScreenOn;
} catch (RemoteException e) {
attemptDeadServiceRecovery(e);
return ROUTE_OFF;
}
|
public java.lang.String | getDriverName()Returns the name of this adapter's driver.
Different NFC adapters may use different drivers. This value is
informational and should not be parsed.
try {
return sService.getDriverName(mPackageName);
} catch (RemoteException e) {
attemptDeadServiceRecovery(e);
return "";
}
|
public NfcExecutionEnvironment | getEmbeddedExecutionEnvironment()Get the {@link NfcExecutionEnvironment} that is embedded with the
{@link NfcAdapter}.
Requires the {@link android.Manifest.permission#WRITE_SECURE_SETTINGS} permission.
return mEmbeddedEe;
|
android.nfc.INfcAdapterExtras | getService()
return sService;
|
private static void | initService(android.nfc.NfcAdapter adapter)get service handles
final INfcAdapterExtras service = adapter.getNfcAdapterExtrasInterface();
if (service != null) {
// Leave stale rather than receive a null value.
sService = service;
}
|
public void | setCardEmulationRoute(com.android.nfc_extras.NfcAdapterExtras$CardEmulationRoute route)Set the routing state of this NFC EE.
This routing state is not persisted across reboot.
Requires the {@link android.Manifest.permission#WRITE_SECURE_SETTINGS} permission.
try {
sService.setCardEmulationRoute(mPackageName, route.route);
} catch (RemoteException e) {
attemptDeadServiceRecovery(e);
}
|