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 8015393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:14:47+00:00 2026-06-04T20:14:47+00:00

My Android app has 2 activities, a main one for info and one for

  • 0

My Android app has 2 activities, a main one for info and one for receiving NFC.

When launching the app for the first time, I can read NFC tags, multiple times – each time bringing up a new activity and showing some info.

If the app is closed but the phone is brought to the NFC tag – it will show the nfc tag activity the first time, but never respond to any other tags again.

What am I doing wrong?!

Manifest part and code for second activity:

<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc" android:required="true" />

<application
android:icon="@drawable/aaa"
android:label="@string/app_name" 
    android:theme="@android:style/Theme.NoTitleBar">

<activity
    android:label="@string/app_name"
    android:name=".MainActivity">
    <intent-filter >
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

<activity 
    android:name=".TagDiscoveredActivity"
    android:screenOrientation="portrait">
    <intent-filter >
        <action android:name="android.nfc.action.TECH_DISCOVERED" />
        <action android:name="android.nfc.action.TAG_DISCOVERED" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
    <meta-data
        android:name="android.nfc.action.TECH_DISCOVERED"
        android:resource="@xml/filter_nfc" />
</activity>
</application>

</manifest>    

The code

public class TagDiscoveredActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.info);
        etc
    }

@Override
public void onNewIntent(Intent intent) {
    setIntent(intent);
    resolveIntent(intent);
}

private void resolveIntent(Intent intent) {
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            //| Intent.FLAG_ACTIVITY_SINGLE_TOP);        

    boolean handled = false;

    // Parse the intent
    final String action = intent.getAction();
    if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action) ||
                NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)) {

        // When a tag is discovered we send it to the service to be save. We
        // include a PendingIntent for the service to call back onto. This
        // will cause this activity to be restarted with onNewIntent(). At
        // that time we read it from the database and view it.
        Parcelable nfctag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
        if (nfctag != null) {
                        //read tag and display here
                    }
                }
            }

    if (!handled) {
        Log.e(logTag, "Unknown intent " + intent);
        finish();
        return;
    }
}

When I run it and log for the second scenario – launching direct from NFC without the app running – the log shows it working first time, but the second time, none of the functions are logging anything.

Thank you for any helpful suggestions.

  • 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-04T20:14:50+00:00Added an answer on June 4, 2026 at 8:14 pm

    I found the answer finally after trying everything.

    The answer is to set the activity to android:launchmode=”singleTask”,
    and in the code in onNewIntent add the lines:

    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an android app that has mutliple activities The first main activity starts
I'm writting an Android's app. Two activities, one has TextEdit to type 'hello message',
I have three activities in my android app. First activity is main application screen
I am working on an android app that has two activities. One is the
I am working on an android app that has a database in which one
We're designing an Android app that has several activities which are working in a
I have a superclass for my Activities (WhereWolfActivity) in my Android app that has
I have an android app that has various activities. for example there is a
I have an Android app with a main tab activity, and several activities within
My Android App has 2 activities. A login screen and a search screen. When

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.