2012-07-19 27 views
1

我嘗試添加使用createApplicationRecord(packagename)作爲Android developer link提到我NdefMessage的申請記錄,我看到了一個錯誤:Android的NFC的Android應用程序記錄錯誤

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

我從Eclipse的更新我的Android SDK管理器。這裏是代碼的一部分:

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") }); 
} 

回答

2

檢查Eclipse中的項目設置已設置了Android「項目構建目標」,以API級別14或更高。 NdefRecord.createApplicationRecord()僅適用於Android 4.0 ICS及更高版本。