Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8966143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:57:49+00:00 2026-06-15T16:57:49+00:00

I am working on creating an Android App that uses NFC to register touches

  • 0

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:

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

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 };

}

I have the following for onNewIntent :

protected void onNewIntent(Intent intent) {
    // NDEF exchange mode
    Log.d("onNewIntent", intent.getAction());
    if (NfcAdapter.ACTION_NDEF_DISCOVERED == (intent.getAction())) {
        NdefMessage[] msgs = getNdefMessages(intent);
        for(int i = 0; i < msgs.length; i++){
            Log.d("onNewIntent", "found new NdefMessage");
        }
     }

    finish();
}

Right now, I run this call:

public void setIdleMessage(){
    InteractionHistory intHist = InteractionHistory.getInstance();
    NdefMessage attackNdefMessage = null;
    NdefRecord[] ndefRecords = new NdefRecord[10];
    ndefRecords[0] = NdefRecord.createMime("application/com.killerapprejji.NfcHandle", new String("attack,attacker:"
            + intHist.getDisplayName() 
            + ",attackerid:" + "1").getBytes());
    attackNdefMessage = new NdefMessage(ndefRecords[0]);
    // need to come up with a way to end if the above try/catch fails
    mNfcAdapter.setNdefPushMessage(attackNdefMessage, this);
}

Expecting it to set the NdefPushMessage. Whenever I touch put the two devices in range of NFC, I still only get the optional “Touch to beam” interface.

Any ideas as to how I can pick up these intents, or if my NdefMessage is even getting sent as I expect?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:57:50+00:00Added an answer on June 15, 2026 at 4:57 pm

    “Touch to Beam” message, is the one defined by Google to push that NDEF message that you are expecting to share on your setNdefPushMessage, so until you push that screen, nothing will be sent to the other device.

    In fact, that API you are using from Android is called Android BEAM

    In the other way, if one device is pushing NDEF messages, it cannot receive messaged until you stop pushing, so you have to implement the NDefPushCallback to catch the succesfull sent of your NDEF message, to stop pushing in the first device, and then it will be able to receive a new intent (NDEF message received) from the other device


    I recommend you make a test app first using URI mime type, or plain text (something easy) to make sure that your “Share Logic” is OK. When you confirm that, you can rollback to your own mime types

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an android app that has to send and receive information from
I'm creating an app that uses the clipboard manager. Since the way of working
I'm working on creating a checkbook app for android using a database to record
I'm working on creating an android app, and I've found that many classes and
I am creating an Android app that uses Twitter4J to read some user info.
I am working on creating a web app that will query event logs on
I am working on an Android app that has multiple screens the user will
I am working on my first ever android app, and I'm creating basic exercise/calorie
I am creating an android app which pulls in RSS Feeds from here http://spaceflight1.nasa.gov/realdata/sightings/cities/rss/index.cgi?country=United_Kingdom&region=England&city=Manchester
i'm kinda new to Android but, i'm creating an app that will use Tabs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.