2

活动有时会从 NfcService 中删除。如何检测从 NfcService 中删除我的活动?以及如何将我的活动重新注册到 NfcService?

▼我的设置如下。

NfcAdapter m_NFC;

@Override
protected void onPause() {
    if (isFinishing()) {
        if (m_NFC != null) {
            m_NFC.disableForegroundDispatch(this);
        }
    }
    super.onPause();
    return;
}

@Override
protected void onResume() {
    super.onResume();
    m_NFC.enableForegroundDispatch(this,PendingIntent.getActivity(this, 0, new Intent(this, getClass()), 0),null,null);
    return;
}

▼启动模式

android:launchMode="singleTask" or "singleTop"

▼日志如下...

09-13 15:13:31.672: E/NfcService(8667): No tag fallback activity found for Intent { act=android.nfc.action.TAG_DISCOVERED flg=0x10000000 (has extras) }
09-13 15:13:31.672: D/NativeNfcTag(8667): Tag lost, restarting polling loop
09-13 15:13:31.672: I/ActivityManager(1577): Starting: Intent { act=android.nfc.action.TAG_DISCOVERED flg=0x10000000 (has extras) } from pid 8667
09-13 15:13:37.125: D/PowerManagerService(1577): mAutoBrightnessTask mPowerState : 3

09-17 14:52:11.556: E/NFC(24672): NFC 服务死机 - 试图恢复 09-17 14:52:11.556: E/NFC(24672): android.os.DeadObjectException 09-17 14:52 :11.556: E/NFC(24672): 在 android.os.BinderProxy.transact(Native Method) 09-17 14:52:11.556: E/NFC(24672): 在 android.nfc.INfcAdapter$Stub$Proxy.isEnabled (INfcAdapter.java:447) 09-17 14:52:11.556: E/NFC(24672): 在 android.nfc.NfcAdapter.isEnabled(NfcAdapter.java:402) 09-17 14:52:11.556: E/NFC (24672): 在 jp.co.aitia.siencemission.FeliCaReceivableActivity.isNfcAdapterEnabled(FeliCaReceivableActivity.java:112) 09-17 14:52:11.556: E/NFC(24672): 在 jp.co.aitia.siencemission.FeliCaReceivableActivity$1 .run(FeliCaReceivableActivity.java:43) 09-17 14:52:11.556: E/NFC(24672): 在 java.util.Timer$TimerImpl.run(Timer.java:284)

4

0 回答 0