Purpose - Check if NFC is present and android beam file transfer is supported. - Android Network

Android examples for Network:NFC

Description

Purpose - Check if NFC is present and android beam file transfer is supported.

Demo Code


//package com.java2s;

import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;

public class Main {
    /**//w w  w.  j av  a  2s. c  o m
     * Purpose - Check if NFC is present and android beam file transfer is supported.
     * Note: This checks for API 17 and above and then checks the feature as earlier versions do not support NFC. 
     * 
     * @param context Current Activity\Context from which this method is called
     * */
    public static boolean IsNFCPresent(Context context) {
        if (context == null)
            return false;
        PackageManager pm = context.getPackageManager();
        return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && pm
                .hasSystemFeature(PackageManager.FEATURE_NFC));
    }
}

Related Tutorials