@Implements(android.nfc.NfcAdapter.class) public class ShadowNfcAdapter extends Object
Constructor | Description |
---|---|
ShadowNfcAdapter() |
Modifier and Type | Method | Description |
---|---|---|
protected void |
disableForegroundDispatch(Activity activity) |
|
protected void |
disableReaderMode(Activity activity) |
|
void |
dispatchTagDiscovered(Tag tag) |
Dispatches the tag onto any registered readers.
|
protected void |
enableForegroundDispatch(Activity activity,
PendingIntent intent,
IntentFilter[] filters,
String[][] techLists) |
|
protected void |
enableReaderMode(Activity activity,
NfcAdapter.ReaderCallback callback,
int flags,
Bundle extras) |
|
Activity |
getDisabledActivity() |
|
Activity |
getEnabledActivity() |
|
IntentFilter[] |
getFilters() |
|
PendingIntent |
getIntent() |
|
NdefMessage |
getNdefPushMessage() |
Returns last set NDEF message, or throws
IllegalStateException if it was never set. |
NfcAdapter.CreateNdefMessageCallback |
getNdefPushMessageCallback() |
Returns last registered callback, or
null if none was set. |
protected static NfcAdapter |
getNfcAdapter(Context context) |
|
NfcAdapter.OnNdefPushCompleteCallback |
getOnNdefPushCompleteCallback() |
|
String[][] |
getTechLists() |
|
protected boolean |
isEnabled() |
|
boolean |
isInReaderMode() |
Returns true if NFC is in reader mode.
|
static void |
reset() |
|
void |
setEnabled(boolean enabled) |
|
protected void |
setNdefPushMessage(NdefMessage message,
Activity activity,
Activity... activities) |
Mocks setting NDEF push message so that it could be verified in the test.
|
protected void |
setNdefPushMessageCallback(NfcAdapter.CreateNdefMessageCallback callback,
Activity activity,
Activity... activities) |
|
static void |
setNfcHardwareExists(boolean hardwareExists) |
Modifies behavior of
getNfcAdapter(Context) to return null , to simulate
absence of NFC hardware. |
protected void |
setOnNdefPushCompleteCallback(NfcAdapter.OnNdefPushCompleteCallback callback,
Activity activity,
Activity... activities) |
Sets callback that should be used on successful Android Beam (TM).
|
@Implementation protected static NfcAdapter getNfcAdapter(Context context)
@Implementation protected void enableForegroundDispatch(Activity activity, PendingIntent intent, IntentFilter[] filters, String[][] techLists)
@Implementation protected void disableForegroundDispatch(Activity activity)
@Implementation(minSdk=19) protected void enableReaderMode(Activity activity, NfcAdapter.ReaderCallback callback, int flags, Bundle extras)
@Implementation(minSdk=19) protected void disableReaderMode(Activity activity)
public boolean isInReaderMode()
public void dispatchTagDiscovered(Tag tag)
@Implementation protected void setNdefPushMessage(NdefMessage message, Activity activity, Activity... activities)
getNdefPushMessage()
to verify that message was set.@Implementation protected void setNdefPushMessageCallback(NfcAdapter.CreateNdefMessageCallback callback, Activity activity, Activity... activities)
@Implementation protected void setOnNdefPushCompleteCallback(NfcAdapter.OnNdefPushCompleteCallback callback, Activity activity, Activity... activities)
The last registered callback is recalled and can be fetched using getOnNdefPushCompleteCallback()
.
@Implementation protected boolean isEnabled()
public static void setNfcHardwareExists(boolean hardwareExists)
getNfcAdapter(Context)
to return null
, to simulate
absence of NFC hardware.public void setEnabled(boolean enabled)
public Activity getEnabledActivity()
public PendingIntent getIntent()
public IntentFilter[] getFilters()
public String[][] getTechLists()
public Activity getDisabledActivity()
public NfcAdapter.CreateNdefMessageCallback getNdefPushMessageCallback()
null
if none was set.public NfcAdapter.OnNdefPushCompleteCallback getOnNdefPushCompleteCallback()
public NdefMessage getNdefPushMessage()
IllegalStateException
if it was never set.@Resetter public static void reset()