Code example for NdefMessage

Methods: toByteArray

0
    public boolean writeToTag(NdefMessage aMessage, Tag tag) {
        if (aMessage != null) {
            message = aMessage;
        } 
 
        int size = message.toByteArray().length;
 
        try { 
            Ndef ndef = Ndef.get(tag);
            if (ndef != null) {
                ndef.connect();
 
                if (!ndef.isWritable()) {
                    toast("Tag is read only"); 
                    return false; 
                } 
                if (ndef.getMaxSize() < size) {
                    toast("Tag capacity is " + ndef.getMaxSize() + " bytes, message is " + size + " bytes.");
                    return false; 
                }