Android Programming Press on the image to return to the main documentation page.

NFC

List of types:

NdefRecord
NFC
TagTechnology

NdefRecord


Events:

None

Members:


  GetAsTextType As String

  GetAsUriType As String

  GetPayload As Byte()

  IsInitialized As Boolean

Members description:

GetAsTextType As String
Reads the payload and returns the stored text.
GetAsUriType As String
Reads the payload and returns the stored Uri.
GetPayload As Byte()
Returns the whole payload.
IsInitialized As Boolean

NFC

Supports reading and writing NFC tags and supports sending messages between two Android devices.
This is an 'Activity Object', it cannot be declared under Sub Process_Globals.

Permissions:

android.permission.NFC

Events:

CreateMessage As List

Members:


  CreateMimeRecord (Mime As String, Data() As Byte) As Object

  CreateUriRecord (Uri As String) As Object

  DisableForegroundDispatch

  EnableForegroundDispatch

  GetNdefRecords (Intent As android.content.Intent) As List

  GetTechList (Intent As android.content.Intent) As String()

  IsEnabled As Boolean [read only]

  IsNdefIntent (Intent As android.content.Intent) As Boolean

  IsSupported As Boolean [read only]

  PreparePushMessage (EventName As String)

Members description:

CreateMimeRecord (Mime As String, Data() As Byte) As Object
Creates an NdefMessage with the given mime type and data.
Note that this method is only supported by Android 4.1+ (API 16).
CreateUriRecord (Uri As String) As Object
Creates an NdefMessage with a Uri payload.
DisableForegroundDispatch
See EnableForegroundDispatch.
EnableForegroundDispatch
Forces all NFC intents to be sent to the current activity. Should be called from Activity_Resume.
DisableForegroundDispatch should called from Activity_Pause.
GetNdefRecords (Intent As android.content.Intent) As List
Retrieves the NdefRecords stored in the Intent object.
GetTechList (Intent As android.content.Intent) As String()
Returns an array with the technologies supported by the NFC tag.
IsEnabled As Boolean [read only]
Returns true if NFC is supported and is enabled.
If IsSupported returned True and IsEnabled returned False then you can show the NFC settings page:

Dim in As Intent
in.Initialize("android.settings.NFC_SETTINGS", "")
StartActivity(in)
IsNdefIntent (Intent As android.content.Intent) As Boolean
Tests whether the Intent contains data read from an NDef tag.
IsSupported As Boolean [read only]
Returns true if an NFC adapter is available.
PreparePushMessage (EventName As String)
Sets the sub that will handle the CreateMessage event.

TagTechnology

Provides access to a scanned tag.

Events:

Connected (Success As Boolean)
RunAsync (Flag As Int, Success As Boolean, Result As Object)

Members:


  Close

  Connect

  Connected As Boolean [read only]

  Initialize (EventName As String, Tech As String, Intent As android.content.Intent)

  IsInitialized As Boolean

  RunAsync (EventName As String, Method As String, Params() As Object, Flag As Int)

Members description:

Close
Closes the connection.
Connect
Connects to the tag. The Connected event will be raised.
Connected As Boolean [read only]
Returns true if there is an active connection.
Initialize (EventName As String, Tech As String, Intent As android.content.Intent)
Initializes the object.
EventName - Set the subs that will handle the events.
Tech - The NFC technology that will be used.
Intent - The intent received in Activity_Resume.
IsInitialized As Boolean
RunAsync (EventName As String, Method As String, Params() As Object, Flag As Int)
Asynchronously runs the given method. This can be used to access native I/O methods.
EventName - The sub that will handle the RunAsync event.
Method - Java method name.
Params - Array of parameters.
Flag - Arbitrary number that will be passed to the RunAsync event.
Top