AndroidNFCpresencedelay
创始人
2024-10-09 11:01:49
0

通过更改NFC读取方式减少延迟

在使用NFC技术进行读取时,可能出现延迟的情况。解决方法是采用非同步读取方式,可以通过PendingIntent来实现。

具体代码示例如下:

private void enableForegroundDispatchSystem(NfcAdapter nfcAdapter, Activity activity) {
    Intent intent = new Intent(activity, activity.getClass());
    intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(activity, 0, intent, 0);
    IntentFilter[] intentFilters = new IntentFilter[]{};
    nfcAdapter.enableForegroundDispatch(activity, pendingIntent, intentFilters, null);
}

@Override
protected void onPause() {
    super.onPause();
    disableForegroundDispatchSystem();
}

@Override
protected void onResume() {
    super.onResume();
    enableForegroundDispatchSystem(nfcAdapter, this);
}

private void disableForegroundDispatchSystem() {
    nfcAdapter.disableForegroundDispatch(this);
}

相关内容

热门资讯

透视好友!xpoker怎么辅助... 透视好友!xpoker怎么辅助,智星德州插件最新版本更新内容详解,大纲教程(一直是有挂)-哔哩哔哩1...
透视开挂!we poker辅助... 透视开挂!we poker辅助器(透视)开挂辅助技巧(切实存在有挂)-哔哩哔哩一、we poker辅...
透视能赢!德普之星app安卓版... 透视能赢!德普之星app安卓版破解版,wepoker私局代打,技法教程(真是是有挂)-哔哩哔哩1、完...
透视大厅!we-poker正规... 透视大厅!we-poker正规吗(透视)开挂辅助挂(原来真的有挂)-哔哩哔哩1、we-poker正规...
透视免费!hhpoker到底可... 透视免费!hhpoker到底可以辅助吗,wepoker透视有吗,演示教程(确实真的有挂)-哔哩哔哩运...
透视好友!wpk官网下载链接,... 透视好友!wpk官网下载链接,佛手在线大菠萝智能辅助器,积累教程(一直有挂)-哔哩哔哩1、佛手在线大...
透视线上!aapoker怎么选... 透视线上!aapoker怎么选牌(透视)开挂辅助神器(好像存在有挂)-哔哩哔哩1、aapoker怎么...
透视透视!HH平台挂,aapo... 透视透视!HH平台挂,aapoker透视脚本,指南教程(确实存在有挂)-哔哩哔哩1)aapoker透...
透视安卓版本!wepoker俱... 透视安卓版本!wepoker俱乐部辅助(透视)开挂辅助插件(确实真的有挂)-哔哩哔哩1.wepoke...
透视规律!德普辅助器怎么用,w... 透视规律!德普辅助器怎么用,wepokerplus到底是挂了吗,总结教程(一直存在有挂)-哔哩哔哩1...