because Android It has good open source advantages , It can be developed by deep customization .  Android Market Application Ratio windows night , Although the supported applications are not as good as windows Multiple systems , However, due to the free and open nature of the system , Many software manufacturers have developed in recent years , More and more applications have joined in , At present, it supports office work , teaching , There's no problem with entertainment . therefore , More and more industries accept and recognize the concept of Android Operating system devices .

At present, most of the industrial control equipment on the market began to use Android The system is up , However, this part of the device is not equipped with native NFC function . In recent years ,NFC The rise of functional requirements , Many industries need to be able to support all the time Android System accessibility Android Equipment and secondary development
NFC Reader writer . therefore , L3-U This NFC Reader writer
emerge as the times require . Used as a USB Drive free   Of NFC Reader writer , Support in windows,Android,linux And other operating systems , Free of charge to provide a variety of systems based on the above SDK, It is convenient for customers to expand their functions and secondary development .

L3-U This USB Drive free NFC The reader has been designed USB drive , Based on Android On the device of the system, only the USB
HOST Authority or adoption OTG Transmission can be used , There is no need to install additional drivers . If you have other non-standard Android equipment , We need to provide devices for compiling and driving . The following are standard with USB
HOST Device access with permission NFC The process of the reader writer . For your reference NFC Reference in the secondary development of reader !

1, In the project AndroidManifest.xml File , Get relevant permissions .
<uses-permission android:name="android.permission.NFC" /> <uses-feature
android:name="android.hardware.nfc" android:required="true" /> <uses-sdk
android:minSdkVersion="12" android:targetSdkVersion="17" /> <intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" /> <category
android:name="android.intent.category.DEFAULT" /> <data
android:mimeType="text/*" /> </intent-filter> <intent-filter> <action
android:name="android.nfc.action.TECH_DISCOVERED" /> </intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/nfc_tech_filter" />
 
<uses-permission android:name="android.permission.NFC" />     <uses-feature  
      android:name="android.hardware.nfc"         android:required="true" /> 
Add this code , Will make the app download in the app store is filtered out not supported NFC Functional devices .
Here are three intent Screening conditions , namely action by

android.nfc.action.NDEF_DISCOVERED,

android.nfc.action.TECH_DISCOVERED,

android.nfc.action.TAG_DISCOVERED.

This step can help android In system NFC The module is scanning to a NFC Find our goal when we get there activity To interact .

android In system NFC The module is scanning to a NFC After the target, the following steps will be taken to find the appropriate treatment NFC News activity. Before that, I will introduce two concepts ,1,Tag On behalf of one NFC target , When android The device scanned a NFC The relevant data will be encapsulated into a Tag example , adopt Intent Pass it on to the right person activity Go and deal with it .2,TagTechnology express NFC Label supported technology , Can pass Tag Of getTechList() obtain .

Tag Distribution steps for :

a, Look first Tag Is the system supported NDEF data , If it is included, it will be distributed for registration action by ACTION_NEDF_DISCOVERED Of activity.

b, If Tag Does not include system supported NDEF Data or registration not found action by ACTION_NDEF_DISCOVERED Of activity, be NFC The system module attempts to distribute to a action by ACTION_TECH_DISCOVERED Of activity.NFC The system module is analyzed first in distribution NFC
Tag Supportive Tag Technology, And then look for support for this kind of thing Tag
Technology Of activity, And then it's packaged Tag Data Intent Distribute to the corresponding activity.

c, If neither of the above is satisfied , Then send action by ACTION_TAG_DISCOVERED Of intent

2, Build a Activity page , For implementation NFC The function of reading and writing .NFC Read write function to achieve the following code :
package cc.lotusnfc; import java.io.IOException; import
java.nio.charset.Charset; import java.sql.Date; import
java.text.SimpleDateFormat; import java.util.Arrays; import cc.lotusnfc.R;
import android.nfc.FormatException; import android.nfc.NdefMessage; import
android.nfc.NdefRecord; import android.nfc.NfcAdapter; import
android.nfc.NfcManager; import android.nfc.Tag; import
android.nfc.tech.MifareClassic; import android.nfc.tech.Ndef; import
android.nfc.tech.NfcA; import android.os.Bundle; import android.os.Parcelable;
import android.annotation.SuppressLint; import android.app.Activity; import
android.app.PendingIntent; import android.content.Context; import
android.content.Intent; import android.content.IntentFilter; import
android.view.Menu; import android.view.View; import android.widget.Button;
import android.widget.EditText; import android.widget.TextView; import
android.widget.Toast; public class MainActivity extends Activity { private
TextView resultText; private PendingIntent pendingIntent; private
IntentFilter[] mFilters; private String[][] mTechLists; private Button
mJumpTagBtn; private boolean isFirst = true; private NfcAdapter m_NfcAdpater;
private EditText m_edtLog; private Intent m_NfcIntent = null; @Override
protected void onCreate(Bundle savedInstanceState) { // obtain nfc Adapter , Judge whether the device supports NFC function
m_NfcAdpater = NfcAdapter.getDefaultAdapter(this); if (m_NfcAdpater == null) {
Toast.makeText(this, "Not Found NfcAdapter!", Toast.LENGTH_SHORT) .show();
//finish(); //return; } else if (!m_NfcAdpater.isEnabled()) {
Toast.makeText(this, "Please Enabled NfcAdapter", Toast.LENGTH_SHORT).show();
//finish(); //return; } super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); m_edtLog = (EditText)
findViewById(R.id.edtLog); m_edtLog.setText(""); pendingIntent =
PendingIntent.getActivity(this, 0, new Intent(this,
getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); IntentFilter ndef =
new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); ndef.addCategory("*/*");
mFilters = new IntentFilter[] { ndef };// filter mTechLists = new String[][] { new
String[] { MifareClassic.class.getName() }, new String[] { NfcA.class.getName()
} };// Label types allowed to scan } @Override public boolean onCreateOptionsMenu(Menu menu) { //
Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu); return true; }
@SuppressLint("NewApi") @Override protected void onResume() { // TODO
Auto-generated method stub super.onResume();
m_NfcAdpater.enableForegroundDispatch(this, pendingIntent, mFilters,
mTechLists); } private NdefMessage createMessage(String text) { NdefRecord[]
record = new NdefRecord[1]; String lang = "en"; byte[] langBytes =
lang.getBytes(Charset.forName("US-ASCII")); byte[] textBytes =
text.getBytes(Charset.forName("UTF-8")); char status = (char)
(langBytes.length); byte[] data = new byte[1 + langBytes.length +
textBytes.length]; data[0] = (byte) status; System.arraycopy(langBytes, 0,
data, 1, langBytes.length); System.arraycopy(textBytes, 0, data, 1 +
langBytes.length, textBytes.length); record[0] = new
NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_TEXT, new byte[0], data);
return new NdefMessage(record); } @Override protected void onNewIntent(Intent
intent) { // TODO Auto-generated method stub super.onNewIntent(intent);
m_NfcIntent = intent; String strWriteText = " Spring sleeps without dawn "; if
(NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) { Tag
tagFromIntent = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); Ndef ndef =
Ndef.get(tagFromIntent); if (ndef != null) { NdefMessage ndefMessage =
createMessage(strWriteText); try { ndef.connect(); // READ NdefMessage msg =
ndef.getNdefMessage(); if(null == msg) return; NdefRecord[] records =
msg.getRecords(); // NdefMessage nmsg = (NdefMessage) msgs[0]; NdefRecord
record = records[0]; String resultStr = ""; if (record.getTnf() ==
NdefRecord.TNF_WELL_KNOWN) { if (Arrays .equals(record.getType(),
NdefRecord.RTD_TEXT)) { byte[] payload = record.getPayload(); if (payload ==
null) return; try { String textEString = ((payload[0] & 0x80) == 0) ? "UTF-8" :
"UTF-16"; int languageCodeLength = payload[0] & 0x3f; resultStr = new
String(payload, languageCodeLength + 1, payload.length - languageCodeLength -
1, textEString); AddLog("Read:" + resultStr); } catch (Exception e) {
e.printStackTrace(); } } } // WRITE ndef.writeNdefMessage(ndefMessage);
AddLog("WRITE:" + strWriteText); ndef.close(); } catch (IOException e) { //
TODO Auto-generated catch block e.printStackTrace(); AddLog("IOException" ); }
catch (FormatException e) { // TODO Auto-generated catch block
e.printStackTrace(); AddLog("FormatException" ); } } } } private void
AddLog(String strLog) { SimpleDateFormat formatter = new
SimpleDateFormat("HH:mm:ss"); Date curDate = new
Date(System.currentTimeMillis());// Get the current time String strDate =
formatter.format(curDate); if (null == m_edtLog) return; String strLogs =
m_edtLog.getText().toString().trim(); if (strLogs.equals("")) { strLogs =
strDate + " " + strLog; } else { strLogs += "\r\n" + strDate + " " + strLog; }
m_edtLog.setText(strLogs); } public void OnClearLogListener(View arg0) { if
(null == m_edtLog) return; m_edtLog.setText(""); } public void
OnSetNfcListener(View arg0) { startActivityForResult(new Intent(
android.provider.Settings.ACTION_WIRELESS_SETTINGS), 0); } public void
OnTestListener(View arg0) { String strWriteText = " Spring sleeps without dawn "; if(null ==
m_NfcIntent) return; if
(NfcAdapter.ACTION_TECH_DISCOVERED.equals(m_NfcIntent.getAction())) { Tag
tagFromIntent = m_NfcIntent.getParcelableExtra(NfcAdapter.EXTRA_TAG); Ndef ndef
= Ndef.get(tagFromIntent); if (ndef != null) { NdefMessage ndefMessage =
createMessage(strWriteText); try { ndef.connect(); // READ NdefMessage msg =
ndef.getNdefMessage(); NdefRecord[] records = msg.getRecords(); // NdefMessage
nmsg = (NdefMessage) msgs[0]; NdefRecord record = records[0]; String resultStr
= ""; if (record.getTnf() == NdefRecord.TNF_WELL_KNOWN) { if (Arrays
.equals(record.getType(), NdefRecord.RTD_TEXT)) { byte[] payload =
record.getPayload(); if (payload == null) return; try { String textEString =
((payload[0] & 0x80) == 0) ? "UTF-8" : "UTF-16"; int languageCodeLength =
payload[0] & 0x3f; resultStr = new String(payload, languageCodeLength + 1,
payload.length - languageCodeLength - 1, textEString); AddLog("Read:" +
resultStr); } catch (Exception e) { e.printStackTrace(); } } } // WRITE
ndef.writeNdefMessage(ndefMessage); AddLog("WRITE:" + strWriteText);
ndef.close(); } catch (IOException e) { // TODO Auto-generated catch block
e.printStackTrace(); } catch (FormatException e) { // TODO Auto-generated catch
block e.printStackTrace(); } } } } }
 

Technology