Android examples for Network:NFC
Checks if the device supports NFC.
/*/*from w w w. j a va 2 s . co m*/ * 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/>. */ //package com.java2s; import android.content.Context; import android.nfc.NfcAdapter; import android.os.Build; public class Main { /** * Checks if the device supports NFC. * * @param context the {@link Context}. * @return true if hardware supports NFC; false otherwise. */ public static boolean supportsBeam(Context context) { return getNfcAdapter(context) != null; } /** * 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; } }