Package org.robolectric.shadows
Class ShadowNfcAdapter
- java.lang.Object
-
- org.robolectric.shadows.ShadowNfcAdapter
-
@Implements(android.nfc.NfcAdapter.class) public class ShadowNfcAdapter extends Object
Shadow implementation ofNfcAdapter
.
-
-
Constructor Summary
Constructors Constructor Description ShadowNfcAdapter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
disable()
protected void
disableForegroundDispatch(Activity activity)
protected void
disableReaderMode(Activity activity)
void
dispatchTagDiscovered(Tag tag)
Dispatches the tag onto any registered readers.protected boolean
enable()
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 the 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).
-
-
-
Method Detail
-
getNfcAdapter
@Implementation protected static NfcAdapter getNfcAdapter(Context context)
-
enableForegroundDispatch
@Implementation protected void enableForegroundDispatch(Activity activity, PendingIntent intent, IntentFilter[] filters, String[][] techLists)
-
disableForegroundDispatch
@Implementation protected void disableForegroundDispatch(Activity activity)
-
enableReaderMode
@Implementation(minSdk=19) protected void enableReaderMode(Activity activity, NfcAdapter.ReaderCallback callback, int flags, Bundle extras)
-
disableReaderMode
@Implementation(minSdk=19) protected void disableReaderMode(Activity activity)
-
isInReaderMode
public boolean isInReaderMode()
Returns true if NFC is in reader mode.
-
dispatchTagDiscovered
public void dispatchTagDiscovered(Tag tag)
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
@Implementation protected boolean isEnabled()
-
enable
@Implementation protected boolean enable()
-
disable
@Implementation protected boolean disable()
-
setNfcHardwareExists
public static void setNfcHardwareExists(boolean hardwareExists)
Modifies the behavior ofgetNfcAdapter(Context)
to returnnull
, to simulate absence of NFC hardware.
-
setEnabled
public void setEnabled(boolean enabled)
-
getEnabledActivity
public Activity getEnabledActivity()
-
getIntent
public PendingIntent getIntent()
-
getFilters
public IntentFilter[] getFilters()
-
getTechLists
public String[][] getTechLists()
-
getDisabledActivity
public Activity getDisabledActivity()
-
getNdefPushMessageCallback
public NfcAdapter.CreateNdefMessageCallback getNdefPushMessageCallback()
Returns last registered callback, ornull
if none was set.
-
getOnNdefPushCompleteCallback
public NfcAdapter.OnNdefPushCompleteCallback getOnNdefPushCompleteCallback()
-
getNdefPushMessage
public NdefMessage getNdefPushMessage()
Returns last set NDEF message, or throwsIllegalStateException
if it was never set.
-
reset
@Resetter public static void reset()
-
-