Example usage for android.nfc NdefRecord toUri

List of usage examples for android.nfc NdefRecord toUri

Introduction

In this page you can find the example usage for android.nfc NdefRecord toUri.

Prototype

public Uri toUri() 

Source Link

Document

Map this record to a URI, or return null if it cannot be mapped.

Currently this method considers the following to be URI records:

  • #TNF_ABSOLUTE_URI records.
  • #TNF_WELL_KNOWN with a type of #RTD_URI .
  • #TNF_WELL_KNOWN with a type of #RTD_SMART_POSTER and containing a URI record in the NDEF message nested in the payload.

    Usage

    From source file:io.v.example.vbeam.vbeamexample.MainActivity.java

    @Override
    protected void onResume() {
        super.onResume();
        Intent intent = getIntent();//from  w w  w .j  av  a2 s  .c o m
        if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
            Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
            if (rawMsgs != null) {
                for (int i = 0; i < rawMsgs.length; i++) {
                    for (NdefRecord r : ((NdefMessage) rawMsgs[i]).getRecords()) {
                        System.out.println("record " + r.toString() + "(" + r.toUri() + ")");
                    }
                }
            }
        }
    }