Torben E
Torben E

Reputation: 411

How do I open a link from an NFC tag?

I want to write a NFC tag that opens a specific note in Google Keep when touched.

I have an URL in the form of https://keep.google.com/u/0/#LIST/<id> that does the desired action of opening the note in the installed Google Keep app on my phone when I read it with a QR-reader or click on it as a link.

When I write this URL to the tag an touch the tag afterwards, it opens in the browser. Is the NFC handler skipping other apps and opening it directly in a browser? When I clear the app-defaults for the browser, it shows a selection menu for the installed browsers after tapping the tag. Does anyone have an idea what I am doing wrong?

Upvotes: 3

Views: 7640

Answers (2)

Michael Roland
Michael Roland

Reputation: 40841

Links on NFC tags are not launched as intents with the typical VIEW action. Consequently, other apps may not pick those links up correctly and you will instead experience the web browser to be opened. Only apps that specifically register for the intent action NDEF_DISCOVERED will be able to receive links from NFC tags. It seems that Google Keep currently does not do this, so there's not much you can do without creating your own wrapper app that handles these URLs and passes them on to Google Keep.

Upvotes: 3

Halil &#214;ZCAN
Halil &#214;ZCAN

Reputation: 109

You should enable deeplinks in your activity. Also you should indicate your activity NFC tag discoverable as follows. You can learn anything about deep linking via this link

<activity
        android:name="ExampleActivity"
        android:label="Example">
        <intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="example.com"
                android:scheme="http" />
            <data android:scheme="https" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.nfc.action.NDEF_DISCOVERED" />

            <category android:name="android.intent.category.DEFAULT" />

            <data android:mimeType="text/plain" />
        </intent-filter>
    </activity>

Upvotes: 1

Related Questions