2013-04-17 2 views
0

NFC를 통해 특정 도메인에 대해 열린 URI를 처리하려고합니다.Android NFC : 앱이 시작되었지만 의도가 의도되지 않았습니다.

매니페스트이 있습니다

<activity android:name="HistoryActivity" 
     android:theme="@android:style/Theme.Light.NoTitleBar" 
     android:screenOrientation="portrait"> 
     <intent-filter> 
      <action android:name="android.nfc.action.NDEF_DISCOVERED" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <data android:scheme="https" 
       android:host="mydomain.me" 
       android:pathPrefix="/x" /> 
     </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="mydomain.me" 
       android:pathPrefix="/x" /> 
     </intent-filter> 
    </activity> 

onResume과 같이 onNewIntent :

@Override 
protected void onResume() { 
    super.onResume(); 
    Intent intent = new Intent(this, this.getClass()); 
    //intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 

    this.handleNfcBeam(intent); 
} 

@Override 
protected void onNewIntent(Intent intent) 
{ 
    setIntent(intent); 

    this.handleNfcBeam(intent); 
} 

와 같은 handleNfcBeam 보이는 : I 빔 올바른 URL이 앱이 경우

protected boolean handleNfcBeam(Intent intent) 
{ 
    String action = intent.getAction(); 

    if (action != null && 
      action.equalsIgnoreCase("android.nfc.action.NDEF_DISCOVERED")) 
    { 

     return true; // todo: process URL 
    } 

    return false; 
} 

을 발사되고있다. 그러나, 행동은 항상 null입니다 !! 내가 잘못하고있는 중이 야 내가 이벤트가 실제로 메시지를 처리 ​​할 수있는 점에 못 했어

...

?

덕분에, 다니엘

답변

0

당신은 당신의 의도가오고있는 경로를 볼 수 this.handleNfcBeam(intent);의 두 라인의 각에 중단 점을 배치 할 수 있습니다. 그런 다음 의도 데이터를 조사하여 귀하가 어떤 의도의 의도를 가지고 있는지 확인하십시오.

태그에 올바른 내용의 NDEF 메시지가 포함되어 있으며 매니페스트의 정의와 일치합니까? scheme, host 및 pathPrefix를 정의 할 때 그 중 세 가지 모두가 충족되어 인 텐트를 트리거해야합니다.

+0

감사합니다. 나는 투표 할만한 평판 포인트가 충분하지 않습니다. - 그리고 나는 여전히 대답을 표시 할 수 없도록 "신비"를 해결하지 못했습니다. –

+0

내가 언급 한 것을 확인 했습니까? 특히 매니페스트에 정의한 내용이 태그에 정확히 포함되어 있는지 확인하십시오. – corvairjo

+0

문제는 실제로 잘못된 NDEF 메시지가 전송 된 것과 같습니다. –

관련 문제