Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


Question:Android NFC App not pushing Ndef messages


I am working on creating an Android App that uses NFC to register touches from device to device. I am using two Nexus 7s for testing.

Ideal use case is to have the App active on one device, not active on the other. The active device pushes an NdefMessage with a record containing some data for the passive device app to deal with. The passive device passes a recording containing some data back to the active app.

I have the following intent filters set up in my manifest:

   android:name=".MainActivity" android:label="@string/title_activity_main">
        
           android:name="android.nfc.action.NDEF_DISCOVERED"/>
           android:mimeType="application/com.killerapprejji.MainActivity"/>
           android:mimeType="application/com.*"/>
           android:mimeType="application/com.killerapprejji.*"/>
           android:mimeType="application/*"/>
           android:name="android.intent.category.DEFAULT"/>
        
  

In my MainActivity I have the following in onCreate to set up the NFC adapter:

mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
PendingIntent pendingIntent = PendingIntent.getActivity(
            this, 0, new Intent(this,
                getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
mNfcPendingIntent = pendingIntent;
    // Intent filters for exchanging over p2p.
if(mNfcAdapter != null){
    IntentFilter ndefDetected = new
                       IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
    IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
    try {
        ndef.addDataType("application/*");    
    }
    catch (MalformedMimeTypeException e) {
        throw new RuntimeException("fail", e);
    }
    this.intentFiltersArray = new IntentFilter[] {ndef, };
    Log.d(this.toString(), "mNfcPendingIntent: ");
    mNdefExchangeFilters = new IntentFilter[] { ndefDetected,defendDetected };

}

 


asked Sep 13, 2013 in Core java by rajesh
edited Sep 12, 2013
0 votes
53 views



Related Hot Questions



Government Jobs Opening


...