How to launch an application without a launch icon by scanning an NFC tag?

I want to run the application by scanning the NFC tag containing the Android Application Record . However, there should not be a launch icon for this application, so I cannot use it CATEGORY_LAUNCHER.

My problem is that if I comment out a line CATEGORY_LAUNCHERin the manifest, the application no longer starts (the search is done on Google Play):

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="app.my">

    <application android:label="@string/app_name">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <!--<category android:name="android.intent.category.LAUNCHER" />-->
            </intent-filter>
        </activity>
    </application>
</manifest>

I also tried adding the following intent filter, but no luck:

<intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="text/plain" />
</intent-filter>

What should I do to make it work? Should I add code in MainActivityto handle the intent NDEF_DISCOVERED?

+4
source share
2 answers

- ( MIME, NFC Forum URI) Android (AAR). AAR (, , ) NDEF .

(.. NDEF ), NDEF_DISCOVERED. . NFC Forum:

<activity android:name=".MainActivity">
    <intent-filter>
        <action android:name="android.nfc.action.NDEF_DISCOVERED" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:scheme="vnd.android.nfc"
              android:host="ext"
              android:pathPrefix="/yourdomain.com:yourtypename"/>
    </intent-filter>
</activity>

AAR , , , Play Store , .

- NDEF_DISCOVERED, AAR MAIN/LAUNCHER ( Android , ). , NDEF_DISCOVERED MAIN/LAUNCHER , AAR .

, , AAR ?

, AAR. AAR NFC Forum "urn: nfc: ext: android.com:pkg", :

<intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:scheme="vnd.android.nfc" android:host="ext"
          android:pathPrefix="/android.com:pkg" />
</intent-filter>
+1

, intent-filter mimeType, :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="app.my">

    <application android:label="@string/app_name">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <!--<category android:name="android.intent.category.LAUNCHER" />-->
            </intent-filter>
            <intent-filter>
                <action android:name="android.nfc.action.NDEF_DISCOVERED" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="application/vnd.app.my" />
            </intent-filter>
        </activity>
    </application>
</manifest>

NdefRecord :

NdefRecord.createMime("application/vnd.app.my", null);

AAR, , , ( ) , . , MIME, , .

+1

All Articles