Code example for NdefMessage

Methods: toByteArray

0
 
  /* 
  * Writes an NdefMessage to a NFC tag 
  */ 
  public static boolean writeNFCTag(NdefMessage message, Tag tag) {
    int size = message.toByteArray().length;
    try { 
        Ndef ndef = Ndef.get(tag);
        if (ndef != null) {
            ndef.connect();
            if (!ndef.isWritable()) {
                return false; 
            } 
            if (ndef.getMaxSize() < size) {
                return false; 
            } 
            ndef.writeNdefMessage(message);
            return true; 
        } else { 
            NdefFormatable format = NdefFormatable.get(tag);
            if (format != null) {