2017-02-01 7 views
0

jmrtdライブラリを使用してパスポートからRFIDを読み取るためにNFCを使用しています。問題は、データが正常に読み込まれた後にnfc関連のインテントを受信しないようにすることですが、現在、タグが検出されたときに、他のアクティビティがフォアグラウンドになっていてもnfcリーディングアクティビティを再度開始します。初めてNFCタグの読み取りを停止する

マイコード:

protected void onResume() { 
     super.onResume(); 
     this.mAdapter.enableForegroundDispatch(this, this.mNfcListener, mIntentFilters, null); 
    } 

    //<editor-fold desc="NFC"> 
    public boolean initNFC() { 
     this.mAdapter = NfcAdapter.getDefaultAdapter(this); 
     if (this.mAdapter == null) { 
      return false; 
     } 
     Intent i = new Intent(this, getClass()); 
     i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 
     this.mNfcListener = PendingIntent.getActivity(this, 0, i, 0); 
     IntentFilter tagFilter = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED); 
     IntentFilter ndefFilter = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); 
     this.mIntentFilters = new IntentFilter[]{tagFilter, ndefFilter}; 
     return true; 
    } 

    protected void onPause() { 
     mAdapter.disableForegroundDispatch(this); 
     super.onPause(); 
    } 

答えて

0

不可能です... あなたの活動は、インテントフィルタのアクションNDEF_DISCOVEREDを持っているので。

これを読む... How to detect NFC tag was removed

関連する問題