Code example for NdefMessage

Methods: getRecords

0
    } 
 
    private void ndefDiscovered(Intent intent) {
        Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
        NdefMessage msg = (NdefMessage) rawMsgs[0];
        String payload = new String(msg.getRecords()[0].getPayload());
        String uri = "spotify:" + payload;
        Intent launcher = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        startActivity(launcher);
    } 
 
    private String getTypeKey(String key) {
        if (key.startsWith("user")) {
            return getString(R.string.keyTypeList);
        } else if (key.startsWith("track")) {
            return getString(R.string.keyTypeTrack);
        } else if (key.startsWith("album")) {
            return getString(R.string.keyTypeAlbum);
        } 
        return getString(R.string.keyTypeUnknown);
Contextual code suggestions in your IDE  Get Codota for Java