简体   繁体   中英

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.

  • 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"> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM