1 回答

TA貢獻(xiàn)1875條經(jīng)驗(yàn) 獲得超3個贊
您只是在第二次處理意圖。
添加一個基于您當(dāng)前onNewIntent()
方法的新方法,如下所示:
private void onNewNfcTag(Intent intent) {
? ? if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())
? ? ? ? ? ? || NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())?
? ? ? ? ? ? || NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) {
? ? ? ? Tag iTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
? ? ? ? mTextView.setText(TagReader.readTag(iTag, intent));
? ? }
}
更改您的onNewIntent()名稱以調(diào)用此新方法:
@Override
protected void onNewIntent(Intent intent) {
? ? super.onNewIntent(intent);
? ? onNewNfcTag(intent);
}
onCreate()從intent from調(diào)用這個相同的方法getIntent():
@Override
protected void onCreate(Bundle savedInstanceState) {
? ? // .... your code already here
? ? onNewNfcTag(getIntent());
}
添加回答
舉報