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