Code example for NfcManager

Methods: getDefaultAdapter

0
		NfcManager mng = (NfcManager)activity.getSystemService(Context.NFC_SERVICE);
		if (mng == null) {
			Log.e(TAG, "no NfcManager");
			return false; 
		} 
		NfcAdapter adapter = mng.getDefaultAdapter();
		if (adapter == null) {
			Log.e(TAG, "no NfcService");
			return false; 
		} 
 
		//newがnullを返すことはない 
		Intent intent = new Intent(activity, activity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
		PendingIntent pendingIntent = PendingIntent.getActivity(
						activity,
						0,		//request code 
						intent,
						0);		//flagなし 
 
		adapter.enableForegroundDispatch(activity, pendingIntent, mFilters, mTechLists);
Experience pair programming with AI  Get Codota for Java