@Test public void testEncode() throws Exception { SmartPosterRecord smartPosterRecord = new SmartPosterRecord(); smartPosterRecord.setTitle(new TextRecord("Test", Charset.forName("UTF8"), Locale.GERMAN)); smartPosterRecord.setUri( new UriRecord("sms:+491234567890?body=Hi!%20Wie%20geht%20es%20dir%3F")); byte[] payload = encoder.encodePayload(smartPosterRecord, messageEncoder); assertEquals(innerSmartPoster, NfcUtils.convertBinToASCII(payload)); }
@Override public WellKnownRecord decodePayload(byte[] payload, NdefMessageDecoder messageDecoder) { SmartPosterRecord smartPosterRecord = new SmartPosterRecord(); List<Record> records = messageDecoder.decodeToRecords(messageDecoder.decode(payload)); for (Record record : records) { if (record instanceof UriRecord) { smartPosterRecord.setUri((UriRecord) record); } else if (record instanceof TextRecord) { smartPosterRecord.setTitle((TextRecord) record); } else if (record instanceof ActionRecord) { smartPosterRecord.setAction((ActionRecord) record); } } return smartPosterRecord; }