Mulgard
Mulgard

Reputation: 10589

Open specific activity with NFC in Android and launch as separate task

Today I managed to write a small app with three pages:

  1. Start-Page with Server Login
  2. Menu Page
  3. NFC Page for NFC-Reading

I also managed to read nfc tags and to print out the information I got from the nfc tag but there are a few questions I have now:

  1. When I am at my Menu Page and place the Tag to read the NFC my Start-Page appears automatically but I want my NFC Page to appear automatically. How can I do that?

  2. I made my app to start automatically when an nfc tag is placed near my smartphone. How can I make the app appear in the list of active and started apps? When I start my app manually it appears in the list of all apps running. If I start my ap automatically using a nfc tag it does not appear in the list of all apps running.

Upvotes: 1

Views: 2658

Answers (1)

ashoke
ashoke

Reputation: 6461

  • To always open your NFC Page when tapped, move TECH_DISCOVERED intent-filter under NFC page activity entry.

    <intent-filter>
        <action android:name="android.nfc.action.TECH_DISCOVERED" />
    </intent-filter>
    
  • use singleTask launch mode for your NFC Page activity

        <activity android:name=".NFCPage"
            android:label="@string/nfc_page"
            android:launchMode="singleTask">
    

Upvotes: 3

Related Questions