Java tutorial
//package com.java2s; /* * This file is part of Flying PhotoBooth. * * Flying PhotoBooth is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Flying PhotoBooth is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Flying PhotoBooth. If not, see <http://www.gnu.org/licenses/>. */ import android.content.Context; import android.nfc.NfcAdapter; import android.os.Build; public class Main { /** * Gets the default NFC adapter. * * @param context the {@link Context}. * @return the NFC adapter; or null if the device does not support NFC. */ private static NfcAdapter getNfcAdapter(Context context) { NfcAdapter nfcAdapter = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { nfcAdapter = NfcAdapter.getDefaultAdapter(context.getApplicationContext()); } return nfcAdapter; } }