@Implements(value=android.nfc.NfcAdapter.class) public class ShadowNfcAdapter extends Object
Constructor and Description |
---|
ShadowNfcAdapter() |
Modifier and Type | Method and Description |
---|---|
protected void |
disableForegroundDispatch(Activity activity) |
protected void |
enableForegroundDispatch(Activity activity,
PendingIntent intent,
IntentFilter[] filters,
String[][] techLists) |
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() |
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 protected void setNdefPushMessage(NdefMessage message, Activity activity, Activity... activities)
Mocks setting NDEF push message so that it could be verified in the test. Use 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)
Sets callback that should be used on successful Android Beam (TM).
The last registered callback is recalled and can be fetched using getOnNdefPushCompleteCallback()
.
@Implementation protected boolean isEnabled()
public static void setNfcHardwareExists(boolean hardwareExists)
Modifies behavior of 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()
Returns last registered callback, or null
if none was set.
public NfcAdapter.OnNdefPushCompleteCallback getOnNdefPushCompleteCallback()
public NdefMessage getNdefPushMessage()
Returns last set NDEF message, or throws IllegalStateException
if it was never set.
@Resetter public static void reset()