1

I am trying to execute

adb shell am start -W -a android.nfc.action.NDEF_DISCOVERED -d "https://www.google.de"

in a way that would be similar to an actual NFC-Tag scan which has some URI (SmartPoster).

This is necessary, as the above command works e.g. with Chrome but not as a deeplink into a Capacitor app.

As far as I've discovered, it is necessary to send some extra data to this intent in order for this to work correctly as a deeplink for my use case.

However, I'm not really an android-dev and the docs are lacking examples regarding the correct syntax and contents of these extras.

According to https://developer.android.com/studio/command-line/adb#IntentSpec

These are the possible extra options to set:

-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE>
--esn <EXTRA_KEY>
--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE>
--ei <EXTRA_KEY> <EXTRA_INT_VALUE>
--el <EXTRA_KEY> <EXTRA_LONG_VALUE>
--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE>
--eu <EXTRA_KEY> <EXTRA_URI_VALUE>
--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]
--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]
--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]
--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]

(copied from: https://stackoverflow.com/a/26517290)

And there seems to be a new option for string arrays:

[--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]
(to embed a comma into a string escape it using "\,")

(copied from https://stackoverflow.com/a/28638589)

According to google, the EXTRA_TAG ist passed as the extra for the intent.

When a tag is discovered, a Tag object is created and passed to a single activity via the NfcAdapter#EXTRA_TAG extra in an android.content.Intent via android.content.Context#startActivity.

Mandatory extra containing the Tag that was discovered for the ACTION_NDEF_DISCOVERED, ACTION_TECH_DISCOVERED, and ACTION_TAG_DISCOVERED intents.

The value of EXTRA_TAG is android.nfc.extra.TAG - see here


So my best guess currently is that something like this might work:

adb shell am start -W -a android.nfc.action.NDEF_DISCOVERED -d "https://www.google.de" --es android.nfc.extra.Tag 'flattened object?!'

Question: Does anybody know how to execute this correctly?

Thank you very much for your help!

Jook
  • 4,564
  • 3
  • 26
  • 53

0 Answers0