MifareClassic Class

Definition

Provides access to MIFARE Classic properties and I/O operations on a Tag.

[Android.Runtime.Register("android/nfc/tech/MifareClassic", DoNotGenerateAcw=true)]
public sealed class MifareClassic : Android.Nfc.Tech.BasicTagTechnology, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/nfc/tech/MifareClassic", DoNotGenerateAcw=true)>]
type MifareClassic = class
    inherit BasicTagTechnology
    interface ITagTechnology
    interface ICloseable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
Attributes
Implements

Remarks

Provides access to MIFARE Classic properties and I/O operations on a Tag.

Acquire a MifareClassic object using #get.

MIFARE Classic is also known as MIFARE Standard.

MIFARE Classic tags are divided into sectors, and each sector is sub-divided into blocks. Block size is always 16 bytes (#BLOCK_SIZE. Sector size varies. <ul> <li>MIFARE Classic Mini are 320 bytes (#SIZE_MINI), with 5 sectors each of 4 blocks. <li>MIFARE Classic 1k are 1024 bytes (#SIZE_1K), with 16 sectors each of 4 blocks. <li>MIFARE Classic 2k are 2048 bytes (#SIZE_2K), with 32 sectors each of 4 blocks. <li>MIFARE Classic 4k are 4096 bytes (#SIZE_4K). The first 32 sectors contain 4 blocks and the last 8 sectors contain 16 blocks. </ul>

MIFARE Classic tags require authentication on a per-sector basis before any other I/O operations on that sector can be performed. There are two keys per sector, and ACL bits determine what I/O operations are allowed on that sector after authenticating with a key. #authenticateSectorWithKeyA and #authenticateSectorWithKeyB.

Three well-known authentication keys are defined in this class: #KEY_DEFAULT, #KEY_MIFARE_APPLICATION_DIRECTORY, #KEY_NFC_FORUM. <ul> <li>#KEY_DEFAULT is the default factory key for MIFARE Classic. <li>#KEY_MIFARE_APPLICATION_DIRECTORY is the well-known key for MIFARE Classic cards that have been formatted according to the MIFARE Application Directory (MAD) specification. <li>#KEY_NFC_FORUM is the well-known key for MIFARE Classic cards that have been formatted according to the NXP specification for NDEF on MIFARE Classic.

Implementation of this class on a Android NFC device is optional. If it is not implemented, then MifareClassic will never be enumerated in Tag#getTechList. If it is enumerated, then all MifareClassic I/O operations will be supported, and Ndef#MIFARE_CLASSIC NDEF tags will also be supported. In either case, NfcA will also be enumerated on the tag, because all MIFARE Classic tags are also NfcA.

<p class="note"><strong>Note:</strong> Methods that perform I/O operations require the android.Manifest.permission#NFC permission.

Java documentation for android.nfc.tech.MifareClassic.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Fields

BlockSize

Size of a MIFARE Classic block (in bytes)

Size1k
Obsolete.

Tag contains 16 sectors, each with 4 blocks.

Size2k
Obsolete.

Tag contains 32 sectors, each with 4 blocks.

Size4k
Obsolete.

Tag contains 40 sectors.

SizeMini
Obsolete.

Tag contains 5 sectors, each with 4 blocks.

TypeClassic
Obsolete.

A MIFARE Classic tag

TypePlus
Obsolete.

A MIFARE Plus tag

TypePro
Obsolete.

A MIFARE Pro tag

TypeUnknown
Obsolete.

A MIFARE Classic compatible card of unknown type

Properties

BlockCount

Return the total number of MIFARE Classic blocks.

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsConnected

Helper to indicate if I/O operations should be possible.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
KeyDefault

The default factory key.

KeyMifareApplicationDirectory

The well-known key for tags formatted according to the MIFARE Application Directory (MAD) specification.

KeyNfcForum

The well-known key for tags formatted according to the NDEF on MIFARE Classic specification.

MaxTransceiveLength

Return the maximum number of bytes that can be sent with #transceive.

PeerReference (Inherited from Object)
SectorCount

Return the number of MIFARE Classic sectors.

Size

Return the size of the tag in bytes

Tag

Get the Tag object backing this ITagTechnology object.

ThresholdClass (Inherited from BasicTagTechnology)
ThresholdType (Inherited from BasicTagTechnology)
Timeout

Get the current #transceive timeout in milliseconds. -or- Set the #transceive timeout in milliseconds.

Type

Return the type of this MIFARE Classic compatible tag.

Methods

AuthenticateSectorWithKeyA(Int32, Byte[])

Authenticate a sector with key A.

AuthenticateSectorWithKeyB(Int32, Byte[])

Authenticate a sector with key B.

BlockToSector(Int32)

Return the sector that contains a given block.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Close()

Disable I/O operations to the tag from this ITagTechnology object, and release resources.

Connect()

Enable I/O operations to the tag from this ITagTechnology object.

Decrement(Int32, Int32)

Decrement a value block, storing the result in the temporary block on the tag.

DecrementAsync(Int32, Int32)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
Get(Tag)

Get an instance of MifareClassic for the given tag.

GetBlockCountInSector(Int32)

Return the number of blocks in the given sector.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
Increment(Int32, Int32)

Increment a value block, storing the result in the temporary block on the tag.

IncrementAsync(Int32, Int32)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
ReadBlock(Int32)

Read 16-byte block.

ReadBlockAsync(Int32)
Restore(Int32)

Copy from a value block to the temporary block.

RestoreAsync(Int32)
SectorToBlock(Int32)

Return the first block of a given sector.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
Transceive(Byte[])

Send raw NfcA data to a tag and receive the response.

TransceiveAsync(Byte[])
Transfer(Int32)

Copy from the temporary block to a value block.

TransferAsync(Int32)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
WriteBlock(Int32, Byte[])

Write 16-byte block.

WriteBlockAsync(Int32, Byte[])

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

ConnectAsync(ITagTechnology)
JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to