Android: NFC tags don't open in duckduckgo

Created on 7 Jun 2020  路  8Comments  路  Source: duckduckgo/Android

1. What I do:
Scan an NFC tag that holds web url

2. What happens:
Google Chrome opens the url

3. What should happen:
Duckduckgo opens the url

After some investigation it seems that duckduckgo is missing the intent-filter.
a quick search for 'nfc' in the google chrome app manifest reveals two entries.
I don't know if nfc permissions are needed to.

image

https://chromium.googlesource.com/chromium/src/+/b71e98cdf14f18cb967a73857826f6e8c568cea0/chrome/android/java/AndroidManifest.xml#245

enhancement hacktoberfest

Most helpful comment

PR has been merged and this feature will be available in our next release.

Shout out to @ashwinpilgaonkar @JeffAment and @andreaskern!

All 8 comments

Thanks, I think it's fine to add the handler to open links from NFC tags.

Hi @cmonfortep, can I work on this?

@ashwinpilgaonkar sure!

Hi @cmonfortep,

Since I dont have any physical NFC tags to test out my changes with, I'm trying to emulate it using another test application that I'm building.

I just have one question - when the NFC tag is detected, does it broadcast an intent in a similar manner as the code snippet given below?

                Intent intent = new Intent("android.nfc.action.NDEF_DISCOVERED");
                intent.setType("text/plain");
                intent.putExtra(NfcAdapter.EXTRA_NDEF_MESSAGES, "Test text");
                sendBroadcast(intent);

According to the docs, yes, it does -> https://developer.android.com/guide/topics/connectivity/nfc/nfc#filter-intents

There's more information about the nfc tags also there https://developer.android.com/guide/topics/connectivity/nfc/nfc#dispatching

According to the docs, yes, it does -> https://developer.android.com/guide/topics/connectivity/nfc/nfc#filter-intents

There's more information about the nfc tags also there https://developer.android.com/guide/topics/connectivity/nfc/nfc#dispatching

Yes, I had gone through these docs earlier but could only find info pertaining to filtering an NFC intent. Whereas, I was more interested in finding out how to mock a physical NFC tag.

Anyway, I've made a PR with the changes, which I was able to test successfully using the following code snippet -

                Intent intent = new Intent();
                intent.setAction("android.nfc.action.NDEF_DISCOVERED");
                intent.setData(Uri.parse("https://www.example.com"));
                startActivity(intent);

IMO it should work the same way with a physical NFC tag as well. Perhaps if someone else has access to one, they can help us out by testing it.

Thanks, I will review the PR this week and will do the testing part too.

PR has been merged and this feature will be available in our next release.

Shout out to @ashwinpilgaonkar @JeffAment and @andreaskern!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arunsathiya picture arunsathiya  路  3Comments

sanogueralorenzo picture sanogueralorenzo  路  4Comments

xfarrow picture xfarrow  路  4Comments

jawadalkassim picture jawadalkassim  路  4Comments

JeffAment picture JeffAment  路  4Comments