Luke
Luke

Reputation: 635

Let another App do critical NFC interactions while your App is actively used

Android Question

Requirements for MainApp:

Let's say I have an Android application (MainApp) that hosts an Activity with the following responsibilities:

  1. Notifying another app (CriticalNfcApp) to start listening for NFC tags.
  2. Displaying results received from CriticalNfcApp.
  3. Offering navigation to other parts of MainApp and informing CriticalNfcApp when to stop listening for NFC tags.
  4. During the listening mode of CriticalNfcApp, MainApp needs to remain in the foreground, as it orchestrates the interactions with CriticalNfcApp.

Requirements for CriticalNfcApp:

  1. Start listening for NFC tags and read out some critical information.
  2. Due to the critical nature of its task, CriticalNfcApp needs to:
    • Be certified.
    • Run in a separate process.
    • isolated in a separate app.

Constraints:

Technical Question:

Is it possible to realize a two-app system where:

Challenges:

  1. Initially, I thought of using a ForegroundService in the CriticalNfcApp project, which hosts an NFCAdapter. However:

    • NFCAdapter only supports creation by passing an instance of Activity, so this does not seem to work.
  2. Another idea was to create a small invisible Activity on top of the screen that shows nothing and instantiates the NFCAdapter.enableReaderMode(Activity,....). However:

    • This potentially would go into the background and get paused or stopped as soon as there is some interaction in the MainApp Activity. This does not seem to be a viable approach either.

Questions:

  1. Does anyone have a working approach for this described constellation?
  2. Are there any ideas on how this could be possible?
  3. What would the architecture look like to achieve this?

Upvotes: 0

Views: 40

Answers (1)

Andrew
Andrew

Reputation: 10152

  1. Nope
  2. Nope, Not really possible (The only thing I can think of is to use Multi-resume on Android 10 and above on devices that have a large enough screen to support this).
  3. A Custom Android ROM with your own System NFC service

Upvotes: 0

Related Questions