What is NFC on Android?

Today, almost every smartphone or Android phone has NFC technology built in. If you wonder what NFC is? 

Well, you already know because you are using it every day for your payment transactions as “Google Pay.” Surprising right? Well, now you know how NFC works. 

NFC (Near Field Communication) is a set of short-range wireless technology that refers to near-device communication that connects a wireless communication network between different devices to communicate with each other, from one Android app you can perform multiple task. 

It is a small range to communicate in devices using NFC tags, it is mostly used in small ranges. For example, lockers and other devices.


Enabling NFC on your device

// write in this code oncreate method

private void alertNfcDisabled () 

   {

 AlertDialog.Builder b = new AlertDialog.Builder(this); 

 b.setTitle("NFC disabled") .setMessage("You have NFC disabled. Please 

enable it in the system settings.") 

.setPositiveButton("Open settings", new DialogInterface.OnClickListener() { 

@Override

 public void onClick(DialogInterface dialog, int which) 

{   user to enable NFC. ParentClass.this.startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); 

})

; return b.create();

 }

After enabling  method 

create object of NFCAdapter.

NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(getApplicationContext());

if ( nfcAdapter == null ) { 

    Log.w("nfc-test", "No NFC adapter present"); 

} else {

if ( nfcAdapter.isEnabled() ) {

// Everything ok: NFC present and enabled.

Log.d("nfc-test", "NFC enabled");

} else {

// NFC present, but disabled. Deal with it.

Log.d("nfc-test", "NFC disabled");

// On example, user can be presented with settings

// screen, where he can enable NFC.

AlertNfcDisabled(); }}

In conclusion, technology has evolved to its best and will get more advanced in the future. 

We are using NFC daily for paying online via the Android mobile app or direct tap card for transferring money during shopping are the best examples. 

NFC can also be used to easily connect with wireless devices and transfer data with Nearby Share. 

365Bloggy May 2, 2024
Share this post
Tags
SUBSCRIBE THIS FORM


Archive