0

I have been instructed to get an NFC tag to open an app that I'm creating using phonegap and I'm adding the following code to my AndroidManifest.xml file.

<intent-filter>
   <action android:name="android.nfc.action.NDEF_DISCOVERED" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:scheme="http"
            android:host="hesdev.nixtel.com"
            android:pathPrefix=""
            android:priority="1000"
            />
</intent-filter> 

I want the NFC tag to open the app and bring it to the front. A URL similar to this is written to my tag:

hesdev.nixtel.com?nfc=kj43hg4g32o2j34hb3g43j453

My question is why is it not working for me? When I scan the NFC tag it should open my application right? It isn't. It opens the web-browser on the tab and brings me to said URL.

edit This is my full manifest file...

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.healthe_scan"
    android:versionCode="1"
    android:versionName="1.0" >

    <supports-screens
    android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:resizeable="true"
    android:anyDensity="true"
    />

    <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<!--uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/-->

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.healthe_scan.MainActivity"
            android:label="@string/app_name" 
            android:configChanges="orientation|keyboardHidden">
            <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:scheme="http"
                     android:host="hesdev.nixtel.com"
                     android:pathPrefix=""
                     android:priority="1000"
                     />
            </intent-filter> 

        </activity>
        <activity 
            android:name="org.apache.cordova.DroidGap" 
            android:label="@string/app_name" 
            android:configChanges="orientation|keyboardHidden"> 
            <intent-filter></intent-filter> 
        </activity>
    </application>

</manifest>
4

1 回答 1

1

约7小时的下水道...

代码没有任何问题 - 是我的标签无法正常工作。无论我的标签编写器在做什么,它都会打开浏览器并将其定向到指定的 URL,但不会启动应用程序。我将我的标签编写器更改为这个...

https://play.google.com/store/apps/details?id=com.nxp.nfc.tagwriter&hl=en

它立即起作用。

于 2013-09-06T15:59:22.070 回答