About the information Android gives to NFC apps launched with int filter

Asked 1 years ago, Updated 1 years ago, 117 views

We are considering passing data to the Android app via NFC Forum Type 4A's NDEF.

After creating an application that reads and writes NDEF on Android, you can automatically launch the application by

  • Write startup conditions as int-filter and include them in the app
  • Keep AAR records in NDEF

I think there are two.

In any case, the OS should have analyzed the NDEF once before calling the app, but can the app use the information in the NDEF record that the OS analyzed?

Or do I have to re-communicate and re-analyze the CC and NDEF files after they are started?

Specifically, for example, there is one NDEF message in the NDEF file, and the NDEF message is

  • NFC well-known-type (Type: "T") "Hello, world!"
  • NFC external-type (Type: "android.com:pkg")

If two NDEF records are recorded, the app with the package ID specified in AAR(android.com:pkg) will automatically start, but should the app always re-communicate and re-analyze to get "Hello, world!" information?That's the question.

android android-intent

2022-09-30 19:35

1 Answers

If the information was analyzed by the Android OS, I think it was included in the Intent when the application was started.
As for the reference , if it is an NDEF message, it can be retrieved from the Intent with the NfcAdapter.EXTRA_NDEF_MESSAGES.

For NDEF messages

Parcelable[] rawMessages=
    int.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
if(rawMessages!=null){
    NdefMessage [ ] messages = new NdefMessage [rawMessages.length];
    for(inti=0;i<rawMessages.length;i++){
        messages[i] = (NdefMessage) rawMessages[i];
    }
    // Process the messages array.
    ...
}

For tags

Tag tag=intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);

If the information is not included in the Intent, I think we need to communicate.


2022-09-30 19:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.