Android Question App launched via NFC intent opens in transient mode (no icon,killed on exit)

Pxs

Member
Licensed User
Hello

I have a b4a app developed to read/write NFC-V (ISO15693) industrial tags.
Such app can also be opened by nfc intent, scanning a tag. Always worked like a charm...until i raised targetSdk to 35

Now, the app works normally ONLY if manually launched. Opening it via nfc intent always creates an ephemeral system task:
-no icon (system gear icon)
-killed when losing foreground
-most importantly, no longer receives further nfc intents, after the first one launching it. Can't scan any more tags with that same app instance.

Activity_Resume, where i used capture the intents with :
B4X:
    Dim ATRIntent As Intent
    Dim IntentData As String
  
    Try
        NFC1.EnableForegroundDispatch
    Catch
        Log("ERROR RESUMING FOREROUND DISPATCH")
    End Try
    
    ATRIntent = Activity.GetStartingIntent
    If ATRIntent.IsInitialized = False  Then
         Return
    End If
...no longer gets invoked. The phone vibrates on tag detection, but doesnt forward any more intent to it



What i tried, adding in the in the manifest:
B4X:
'new attributes i tinkered with
SetActivityAttribute(Main, "android:launchMode", "singleTop")
SetActivityAttribute(Main, "android:exported", "true")
SetActivityAttribute(Main, "android:taskAffinity", "${applicationId}")


'intent filter that was already there, and still works. The filter file restricts to nfcv tags
AddActivityText(Main,
    <intent-filter>
        <action android:name="android.nfc.action.TECH_DISCOVERED"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
    <meta-data
        android:name="android.nfc.action.TECH_DISCOVERED"
        android:resource="@xml/tech_filter" />
)
...and nothing helped.


What happened? How can i solve this? I don't want to disable the option to launch the app automatically via intent, but right now the users are confused and are starting to think that my app 'breaks' and 'crashes', unaware that they're launching an ephemeral task, and not the real app, thanks to google changes...

Thanks in advance!
 
Solution
Solved it couple hours after posting 🙄
If anyone finds the thread and has my same issue, try replacing

B4X:
SetActivityAttribute(Main, "android:launchMode", "singleTop")
with
B4X:
SetActivityAttribute(Main, "android:launchMode", "singleTask")

While also keeping the other 3 SetActivityAttribute rows as posted above

Pxs

Member
Licensed User
Solved it couple hours after posting 🙄
If anyone finds the thread and has my same issue, try replacing

B4X:
SetActivityAttribute(Main, "android:launchMode", "singleTop")
with
B4X:
SetActivityAttribute(Main, "android:launchMode", "singleTask")

While also keeping the other 3 SetActivityAttribute rows as posted above
 
Upvote 0
Solution
Top