jef
jef

Reputation: 117

My android application is not one of the default application when i scan an nfc tag

I have a problem with the intent filters.

I want to write an application that could read all the nfc tags available by android and i don't understand why my application is not visible by the system when i scan a tag... Indeed, the system offers me the possibilty to launch the others applications i have installed but not my application.

Here is the my manifest.xml :

<uses-permission android:name="android.permission.NFC" />

<uses-feature
    android:name="android.hardware.nfc"
    android:required="true" />
<application 
...
   <activity
        android:name=".read.ReadActivity"
        android:label="NfcSamples" 
        android:launchMode="singleTask">
        <intent-filter>
            <action android:name="android.nfc.action.NDEF_DISCOVERED" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.nfc.action.TECH_DISCOVERED" />
        </intent-filter>
        <meta-data
            android:name="android.nfc.action.TECH_DISCOVERED"
            android:resource="@xml/filter_nfc" />
        <intent-filter>
            <action android:name="android.nfc.action.TAG_DISCOVERED" />

        </intent-filter>
    </activity>
</application>

I precise that I don't want to launch specifics tags but read all the tags availables.

What do I missed ?

Upvotes: 1

Views: 1752

Answers (2)

İsmet Alkan
İsmet Alkan

Reputation: 5447

Here's my AndroidManifest.xml of the project that I read/write/authenticate Mifare Classic/Ultralight/Desfire/DesfireEV1 tags:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="nfcapp.app"
  android:versionCode="1"
  android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.NFC"></uses-permission>

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name="nfcapp.app.NFCAppActivity"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <!-- Handle notes detected from outside our application -->
        <intent-filter>
            <action android:name="android.nfc.action.NDEF_DISCOVERED" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/plain" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.nfc.action.TAG_DISCOVERED" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

</application>

Hope it helps.

Upvotes: 1

NFC guy
NFC guy

Reputation: 10228

What you want to do, is simply not possible. Android launches the app with the most specific intent filter that matches. So, in general, there will often be an app with a more specific intent filter (e.g. the complete URL) that matches, so that app will be started instead of your app.

Upvotes: 0

Related Questions