NFC interface adaptation, reading and writing tags (Note and Galaxy series)

NFC interface adaptation, reading and writing tags (Note and Galaxy series)

Source code introduction

For NFC models, you can read and write tags.
Source code running screenshot

y

Source code snippet

  1. /Write content
  2. toWBtn=(Button)findViewById(R.id.toWBtn);
  3. toWBtn.setOnClickListener( new OnClickListener() {
  4. @Override  
  5. public   void onClick(View arg0) {
  6. // TODO Auto-generated method stub  
  7. Intent intent= new Intent(MainActivity. this ,Write2Nfc. class );
  8. startActivity(intent);
  9. }
  10. });
  11. //NFC adapter, all NFC operations are performed from this adapter  
  12. nfcAdapter = NfcAdapter.getDefaultAdapter( this );
  13. if (!ifNFCUse()){
  14. return ;
  15. }
  16. //The Intent to be called, used to repeat the jump to be executed after being triggered by the Intent  
  17. pendingIntent = PendingIntent.getActivity( this , 0 , new Intent( this ,
  18. getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0 );
  19. //Set the tag action to be filtered. Only ACTION_NDEF_DISCOVERED type is accepted here.  
  20. ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
  21. ndef.addCategory( "*/*" );
  22. mFilters = new IntentFilter[] { ndef }; // Filter  
  23. mTechLists = new String[][] { new String[] { NfcA. class .getName() },
  24. new String[] { NfcF. class .getName() },
  25. new String[] { NfcB. class .getName() },
  26. new String[] { NfcV. class .getName() } }; // Tag types allowed to be scanned  
  27.          

Source code link: http://download..com/data/1978596

<<:  BlackBerry CEO: It's unfair that Apple doesn't develop apps for us

>>:  Nine-grid password lock entry program

Recommend

Phoenix.com announces massive layoffs; established portals are transforming

[[147697]] Following the massive layoffs at Sina ...

Picture description: Please keep this winter “safety knowledge gift pack”!

As winter approaches, the temperature continues t...

Taking advantage of the Valentine's Day poster, Durex is shining again!

February 14th, Valentine's Day has always bee...

Peak has passed, consumer expectations for wearable devices plummet

[[146121]] Interest in the Apple Watch and other ...

Insights | Only by keeping calm can you achieve great things

Famous Artists Gallery | Grice, a Russian painter...

Scientists weighed the glaciers and found out they were so thin...

In December 2022, the United Nations General Asse...

16 Free Ways to Promote SaaS Overseas (Part 1)

Here are 16 of the best ways to promote your prod...