源码简介
针对NFC机型,可以对标签进行读写操作。
源码运行截图
y
源码片段
- /写入内容
- toWBtn=(Button)findViewById(R.id.toWBtn);
- toWBtn.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View arg0) {
- // TODO Auto-generated method stub
- Intent intent=new Intent(MainActivity.this,Write2Nfc.class);
- startActivity(intent);
- }
- });
- //NFC适配器,所有的关于NFC的操作从该适配器进行
- nfcAdapter = NfcAdapter.getDefaultAdapter(this);
- if(!ifNFCUse()){
- return;
- }
- //将被调用的Intent,用于重复被Intent触发后将要执行的跳转
- pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this,
- getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
- //设定要过滤的标签动作,这里只接收ACTION_NDEF_DISCOVERED类型
- ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
- ndef.addCategory("*/*");
- mFilters = new IntentFilter[] { ndef };// 过滤器
- mTechLists = new String[][] { new String[] { NfcA.class.getName() },
- new String[] { NfcF.class.getName() },
- new String[] { NfcB.class.getName() },
- new String[] { NfcV.class.getName() } };// 允许扫描的标签类型
源码链接:http://down.51cto.com/data/1978596