Class ShadowNfcAdapter


  • @Implements(android.nfc.NfcAdapter.class)
    public class ShadowNfcAdapter
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void disableForegroundDispatch​(android.app.Activity activity)  
      protected void disableReaderMode​(android.app.Activity activity)  
      void dispatchTagDiscovered​(android.nfc.Tag tag)
      Dispatches the tag onto any registered readers.
      protected void enableForegroundDispatch​(android.app.Activity activity, android.app.PendingIntent intent, android.content.IntentFilter[] filters, java.lang.String[][] techLists)  
      protected void enableReaderMode​(android.app.Activity activity, android.nfc.NfcAdapter.ReaderCallback callback, int flags, android.os.Bundle extras)  
      android.app.Activity getDisabledActivity()  
      android.app.Activity getEnabledActivity()  
      android.content.IntentFilter[] getFilters()  
      android.app.PendingIntent getIntent()  
      android.nfc.NdefMessage getNdefPushMessage()
      Returns last set NDEF message, or throws IllegalStateException if it was never set.
      android.nfc.NfcAdapter.CreateNdefMessageCallback getNdefPushMessageCallback()
      Returns last registered callback, or null if none was set.
      protected static android.nfc.NfcAdapter getNfcAdapter​(android.content.Context context)  
      android.nfc.NfcAdapter.OnNdefPushCompleteCallback getOnNdefPushCompleteCallback()  
      java.lang.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​(android.nfc.NdefMessage message, android.app.Activity activity, android.app.Activity... activities)
      Mocks setting NDEF push message so that it could be verified in the test.
      protected void setNdefPushMessageCallback​(android.nfc.NfcAdapter.CreateNdefMessageCallback callback, android.app.Activity activity, android.app.Activity... activities)  
      static void setNfcHardwareExists​(boolean hardwareExists)
      Modifies behavior of getNfcAdapter(Context) to return null, to simulate absence of NFC hardware.
      protected void setOnNdefPushCompleteCallback​(android.nfc.NfcAdapter.OnNdefPushCompleteCallback callback, android.app.Activity activity, android.app.Activity... activities)
      Sets callback that should be used on successful Android Beam (TM).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ShadowNfcAdapter

        public ShadowNfcAdapter()
    • Method Detail

      • getNfcAdapter

        @Implementation
        protected static android.nfc.NfcAdapter getNfcAdapter​(android.content.Context context)
      • enableForegroundDispatch

        @Implementation
        protected void enableForegroundDispatch​(android.app.Activity activity,
                                                android.app.PendingIntent intent,
                                                android.content.IntentFilter[] filters,
                                                java.lang.String[][] techLists)
      • disableForegroundDispatch

        @Implementation
        protected void disableForegroundDispatch​(android.app.Activity activity)
      • enableReaderMode

        @Implementation(minSdk=19)
        protected void enableReaderMode​(android.app.Activity activity,
                                        android.nfc.NfcAdapter.ReaderCallback callback,
                                        int flags,
                                        android.os.Bundle extras)
      • disableReaderMode

        @Implementation(minSdk=19)
        protected void disableReaderMode​(android.app.Activity activity)
      • isInReaderMode

        public boolean isInReaderMode()
        Returns true if NFC is in reader mode.
      • dispatchTagDiscovered

        public void dispatchTagDiscovered​(android.nfc.Tag tag)
        Dispatches the tag onto any registered readers.
      • setNdefPushMessage

        @Implementation
        protected void setNdefPushMessage​(android.nfc.NdefMessage message,
                                          android.app.Activity activity,
                                          android.app.Activity... activities)
        Mocks setting NDEF push message so that it could be verified in the test. Use getNdefPushMessage() to verify that message was set.
      • setNdefPushMessageCallback

        @Implementation
        protected void setNdefPushMessageCallback​(android.nfc.NfcAdapter.CreateNdefMessageCallback callback,
                                                  android.app.Activity activity,
                                                  android.app.Activity... activities)
      • setOnNdefPushCompleteCallback

        @Implementation
        protected void setOnNdefPushCompleteCallback​(android.nfc.NfcAdapter.OnNdefPushCompleteCallback callback,
                                                     android.app.Activity activity,
                                                     android.app.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()
      • setNfcHardwareExists

        public static void setNfcHardwareExists​(boolean hardwareExists)
        Modifies behavior of getNfcAdapter(Context) to return null, to simulate absence of NFC hardware.
      • setEnabled

        public void setEnabled​(boolean enabled)
      • getEnabledActivity

        public android.app.Activity getEnabledActivity()
      • getIntent

        public android.app.PendingIntent getIntent()
      • getFilters

        public android.content.IntentFilter[] getFilters()
      • getTechLists

        public java.lang.String[][] getTechLists()
      • getDisabledActivity

        public android.app.Activity getDisabledActivity()
      • getNdefPushMessageCallback

        public android.nfc.NfcAdapter.CreateNdefMessageCallback getNdefPushMessageCallback()
        Returns last registered callback, or null if none was set.
      • getOnNdefPushCompleteCallback

        public android.nfc.NfcAdapter.OnNdefPushCompleteCallback getOnNdefPushCompleteCallback()
      • getNdefPushMessage

        public android.nfc.NdefMessage getNdefPushMessage()
        Returns last set NDEF message, or throws IllegalStateException if it was never set.
      • reset

        @Resetter
        public static void reset()