2 Replies Latest reply on Mar 18, 2015 3:17 AM by Mauro Soro

    write multiple information in nfc tag

    Mauro Soro

      Hi all,

       

      I would try to write in an nfc tag with Rhodes nfc api a multiple message (code for open an application and a simple string).

      Following the rhomobile doc I am able to detect the tag and write a simple string but I'm not able to write a composed tag.

      I am using a Topaz 512 tag and I have the bytes space to write this information (tested with simple app from play store).

       

      The code I try to use is the following

       

      payload = Rho::NFCManager.make_payload_with_well_known_text("en", "TEST")

          hash = {

            'id' => [0],

            'type' => Rho::NdefRecord:: RTD_TEXT,

            'tnf' => Rho::NdefRecord::TNF_WELL_KNOWN,

            'payload' => payload

          }

        

        

        payload = Rho::NFCManager.make_payload_with_absolute_uri('com.packagename.appname')

        hash1 = {

        'id' => [1],

        'tnf' => Rho::NdefRecord::TNF_EXTERNAL_TYPE,

        'payload' => payload

      }

          record = []

            record[0] = Rho::NFCManager.make_NdefRecord_from_hash(hash)

            record[1] = Rho::NFCManager.make_NdefRecord_from_hash(hash1)

        

        

      msg = Rho::NFCManager.make_NdefMessage_from_array_of_NdefRecord(record)

       

       

      I have added in the AndroidManifest.xml the following line

       

      <intent-filter>

        <category android:name="android.intent.category.DEFAULT"/>

        <action android:name="android.nfc.action.TECH_DISCOVERED" />

        <data android:host="com.packagename.appname" android:scheme="http" />

      </intent-filter>

       

       

      and in the filter_nfc there is this line

       

      <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

          <!-- capture all MIFARE Classics with NDEF payloads -->

          <tech-list>

              <tech>android.nfc.tech.MifareClassic</tech>

              <tech>android.nfc.tech.Ndef</tech>

          </tech-list>

      </resources>

       

       

      But when I execute the test app it crashes. Can anyone explain me where is the error and how can I solve it?

       

      Thanks, best regards,

      Mauro