Code example for NfcAdapter

Methods: enableForegroundDispatchenableForegroundNdefPushisEnabled

0
    protected void onResume() { 
        // TODO Auto-generated method stub 
        super.onResume(); 
         
        // check if NFC is enabled on device 
        if(!mNfcAdapter.isEnabled()){
            //TODO enable nfc 
            System.out.println("NFC not enabled!");
        } 
         
        if(true){ 
            System.out.println("Start Transmitting..");
             
            String text=("Beam me up, Android! \n\n"+"Beam Time: "+ System.currentTimeMillis());
             
            NdefMessage msg=new NdefMessage(
                    new NdefRecord[]{     
                            new NdefRecord(
                            NdefRecord.TNF_WELL_KNOWN,
                            NdefRecord.RTD_TEXT,
                            NFC_MESSAGE_MIME.getBytes(),
                            text.getBytes() )
                            } 
                    ); 
             
            mNfcAdapter.enableForegroundNdefPush(this, msg);
            mNfcAdapter.enableForegroundDispatch(this,  mPendingIntent, mFilters, null);
        } 
         
    } 
 
     
Contextual code suggestions in your IDE  Get Codota for Java