3

特定のWebサイトのURIを含むNDEFメッセージを受信したときにのみトリガーされるインテントフィルターを定義しようとしています。

私はそれを次のように定義しています:

        <intent-filter>
            <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="http" />
            <data android:host="ta.bcntouch.com" />
        </intent-filter>

しかし、それはそのようにトリガーされません。私も試しました:

            <data android:scheme="http"android:host="ta.bcntouch.com" />

運がない。DEFAULTだけでも。要素を削除すると、要素がトリガーされます。

これはできますか?Androidのドキュメントには、要素でMIMEタイプを使用した例のみが示されています。

助けていただければ幸いです。

4

3 に答える 3

5

これが私が最終的に使用したフィルターで、特定の既知のURLの組み合わせの数をキャプチャします。

ホストフィールドの先頭にある「*」を使用すると、サブドメインにあるテストサーバーでテストするときに同じフィルターを使用したり、名前に同じ形式を使用したりできます。

2番目の(表示)ものは、Webページや電子メールなどから同じURL形式をキャプチャします...:

        <intent-filter>
          <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
          <category android:name="android.intent.category.DEFAULT"/>
            <data android:scheme="http"
                  android:host="*ta.bcntouch.com" 
                  android:pathPattern="/p/.*" />
            <data android:scheme="http"
                  android:host="*ta.bcntouch.com" 
                  android:pathPattern="/l/.*" />
            <data android:scheme="http"
                  android:host="*ta.bcntouch.com" 
                  android:pathPattern="/a.*" />
            <data android:scheme="http"
                  android:host="*ta.bcntouch.com" 
                  android:pathPattern="/t.*" />
        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="http"
                  android:host="*ta.bcntouch.com" 
                  android:pathPattern="/p/.*" />
            <data android:scheme="http"
                  android:host="*ta.bcntouch.com" 
                  android:pathPattern="/l/.*" />
            <data android:scheme="http"
                  android:host="*ta.bcntouch.com" 
                  android:pathPattern="/a.*" />
            <data android:scheme="http"
                  android:host="*ta.bcntouch.com" 
                  android:pathPattern="/t/.*" />
        </intent-filter>
于 2012-10-18T07:51:30.520 に答える
4

このフォーマットは私のために働きます

<data android:scheme="http" android:host="www.domain.com" android:pathPattern=".*" />
于 2012-02-03T19:34:06.960 に答える
-1

似たようなことをしましたが、URIは使えないと思います。インテントフィルターを使用して、MIME ndefメッセージを記述し、x-myapp/mydemoなどのカスタムmimeタイプをアクティビティに割り当てる必要があります。次に、たとえばURLなどの任意のコンテンツを読み取り、たとえばWebブラウザをトリガーできます。

于 2011-05-06T12:27:53.573 に答える