nfc

nfc开关

nfc读写 读:id/.类型/Hash

nfc访真

其实很简单,开启设置中的NFC功能,把系统音量调到最大,
拿一张公交卡之类的放到手机背后,能够听到系统提示声音就代表NFC功能存在,电池为原版!

 

NFC技术在手机中可以有三种功能状态,一是卡模拟状态,利用RFID等技术,实现支付卡、门禁卡等功能;二是识读器状态,利用手机屏幕读取信息,包括智能标签、海报等;另一种则是自助支付功能。

 

 

private NdefRecord createRecord()throwsUnsupportedEncodingException{ 
   
String text       ="Hello, World!"; 
   
String lang       ="en"; 
   
byte[] textBytes  = text.getBytes(); 
   
byte[] langBytes  = lang.getBytes("US-ASCII"); 
   
int    langLength = langBytes.length; 
   
int    textLength = textBytes.length; 
   
byte[] payload    =newbyte[1+ langLength+ textLength]; 
 
   
// set status byte (see NDEF spec for actual bits) 
    payload
[0]=(byte) langLength; 
 
   
// copy langbytes and textbytes into payload 
   
System.arraycopy(langBytes,0, payload,1,              langLength); 
   
System.arraycopy(textBytes,0, payload,1+ langLength, textLength); 
 
   
NdefRecord record =newNdefRecord(NdefRecord.TNF_WELL_KNOWN,  
                                       
NdefRecord.RTD_TEXT,  
                                       
newbyte[0],  
                                       payload
); 
 
   
return record; 
} 

Then we write the record as an NDEF message:

private void write(Tag tag) throws IOException, FormatException { 
    NdefRecord[] records = { createRecord() }; 
    NdefMessage  message = new NdefMessage(records); 
 
    // Get an instance of Ndef for the tag. 
    Ndef ndef = Ndef.get(tag); 
 
    // Enable I/O 
    ndef.connect(); 
 
    // Write the message 
    ndef.writeNdefMessage(message); 
 
    // Close the connection 
    ndef.close(); 
} 

 

 

http://code.google.com/p/openmobster/wiki/NFC

http://www.lvtafeiyan.com/article/xiaoshuo/123.html

http://www.cnblogs.com/doandroid/archive/2011/11/29/2267404.html

http://blog.csdn.net/dadahacker/article/details/6554686

http://blog.csdn.net/pku_android/article/details/7430788

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值