Code example for NdefMessage

Methods: toByteArray

0
     * write a message to a tag, handling various error conditions by returning 
     * false. If context != null, it makes Toast with the result 
     */ 
    public static boolean writeTag(Context context, NdefMessage message, Tag tag)
    { 
        int size = message.toByteArray().length;
 
        try 
        { 
            Ndef ndef = Ndef.get(tag);
            if (ndef != null)
            { 
                ndef.connect();
 
                if (!ndef.isWritable())
                { 
                    toast(context, "Tag is read-only.");
                    return false; 
                } 
                if (ndef.getMaxSize() < size)
                {