Question

I am trying to add an application record using createApplicationRecord(packagename) as mentioned in the Android developer link to my NdefMessage and I see an error:

The method createApplicationRecord(String) is undefined for the type NdefRecord

I have updated my Android SDK Manager from Eclipse. Here is the part of code:

private NdefMessage getMessageAsNdef() {
    byte[] textBytes = mInfo.getBytes();
    NdefRecord textRecord = new NdefRecord(NdefRecord.TNF_MIME_MEDIA,
            "text/plain".getBytes(), new byte[] {}, textBytes);
    return new NdefMessage(new NdefRecord[] { textRecord, NdefRecord.createApplicationRecord("com.nfcgeo.mypackage") });
}
Was it helpful?

Solution

Check if your project settings in Eclipse have set the Android "Project Build Target" to API level 14 or higher. NdefRecord.createApplicationRecord() is only available in Android 4.0 ICS and later.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top