Android NfcManager - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android NfcManager class.

This code example shows how to use the following methods:getDefaultAdapter
		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);
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getDefaultAdapter
		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);
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getDefaultAdapter
    public boolean NfcGetDefaultAdapter() { 
        Debug.Log("NfcGetDefaultAdapter get NFC Service"); 
        if(mNfcAdapter == null) {
            mNfcManager = (NfcManager) mContext.getSystemService(Context.NFC_SERVICE);
            if (mNfcManager != null){
                mNfcAdapter = mNfcManager.getDefaultAdapter();
            } 
            else { 
                Debug.Log("mNfcAdapter Fail"); 
                return true; 
            } 
        } 
        Debug.Log("mNfcAdapter SUCCESS"); 
        return false; 
    } 
 
    public void SetTestEnv() { 
        byte[] reg_set = new byte[10];
        Debug.Log("SetTestEnv::In"); 
 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getDefaultAdapter
        return wm.isWifiEnabled();
    } 
 
    private boolean isNfcEnabled() { 
        NfcManager nm = (NfcManager) getActivity().getSystemService(Context.NFC_SERVICE);
        NfcAdapter na = nm.getDefaultAdapter();
        return (na != null) && na.isEnabled();
    } 
 
    private boolean isAndroidBeamEnabled() { 
        NfcManager nm = (NfcManager) getActivity().getSystemService(Context.NFC_SERVICE);
        NfcAdapter na = nm.getDefaultAdapter();
        return (na != null) && na.isNdefPushEnabled();
    } 
 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getDefaultAdapter
	} 
 
	public void InitialDetect() 
	{ 
		manager = (NfcManager)getSystemService(Context.NFC_SERVICE);
		adapter = manager.getDefaultAdapter();
		nfc_intent = new Intent(this,getClass());
		nfcPendingIntent = PendingIntent.getActivity(this, 0, nfc_intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
		nfc_tech = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED);
		nfcFilter = new IntentFilter[]{nfc_tech};
		tech_list = new String[][]{new String[]{NfcA.class.getName()}};
	} 
	 
	public void callMaterial(Intent intent)
	{ 
		String action = intent.getAction();
		Log.d("Tag_type",action);
		if(NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action))
		{ 
			Tag tagContent = intent.getParcelableExtra(action);
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getDefaultAdapter
	} 
	 
	private void Decration() 
	{ 
		manager = (NfcManager)getSystemService(NFC_SERVICE);
		adapter = manager.getDefaultAdapter();
		nfc_intent = new Intent(this,getClass());
		nfcPendingIntent = PendingIntent.getActivity(this, 0, nfc_intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
		nfc_tech = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED);
		nfcFilter = new IntentFilter[]{nfc_tech};
		tech_list = new String[][]{new String[]{NfcA.class.getName()}};
	}   
 
	@Override 
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present. 
		getMenuInflater().inflate(R.menu.main, menu);
		return true; 
	} 
 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getDefaultAdapter
	@Override 
	protected void onPause() { 
		super.onPause(); 
		 
		NfcManager manager = (NfcManager) getSystemService(NFC_SERVICE);
        manager.getDefaultAdapter().disableForegroundNdefPush(this);
	} 
 
	@Override 
	protected void onResume()  { 
		super.onResume(); 
		 
		NfcManager manager = (NfcManager) getSystemService(NFC_SERVICE);
        NdefRecord rec = new NdefRecord(NdefRecord.TNF_ABSOLUTE_URI, NdefRecord.RTD_URI, new byte[0],share.getBytes());
		manager.getDefaultAdapter().enableForegroundNdefPush(this, new NdefMessage(new NdefRecord[]{rec}));
	} 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getDefaultAdapter
	{ 
		super.onResume(); 
		 
		// enable foreground dispatch for nfc 
		NfcManager manager = (NfcManager)getSystemService(Context.NFC_SERVICE);
		adapter = manager.getDefaultAdapter();
		adapter.enableForegroundDispatch(this, pendingIntent, intentFiltersArray, techList);
	} 
	 
	/** 
	 * onPause 
	 *  
	 * executed when this activity is paused. 
	 */ 
	@Override 
	protected void onPause()  
	{ 
		super.onPause(); 
		 
		// disable foreground dispatch for nfc 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android NfcManager Questions & Answers:

See Code Examples for Android NfcManager Methods: