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);
}

相关内容

热门资讯

透视脚本!德普软件,wepok... 透视脚本!德普软件,wepoker有辅助功能吗,经验教程(其实真的有挂)-哔哩哔哩该软件可以轻松地帮...
透视规律!wpk控制牌是真的吗... 透视规律!wpk控制牌是真的吗,wpk有辅助吗,资料教程(切实是真的挂)-哔哩哔哩1)wpk控制牌是...
透视总结!约局吧德州真的有透视... 透视总结!约局吧德州真的有透视挂吗,wepoker私人定制透视,模板教程(本来是有挂)-哔哩哔哩1、...
透视辅助!poker worl... 透视辅助!poker world辅助器,wepoker底牌透视,阶段教程(一贯存在有挂)-哔哩哔哩透...
透视讲解!hhpoker辅助挂... 透视讲解!hhpoker辅助挂是真的吗,智星德州辅助译码插件靠谱吗,练习教程(原来有挂)-哔哩哔哩1...
透视苹果版!佛手在线是不是有挂... 透视苹果版!佛手在线是不是有挂,aapoker免费透视脚本,学习教程(真是有挂)-哔哩哔哩1、很好的...
透视代打!wepoker辅助软... 透视代打!wepoker辅助软件视频,wepoker透视底牌,指南书教程(其实是有挂)-哔哩哔哩1、...
透视系统!红龙poker辅助工... 透视系统!红龙poker辅助工具,wepoker到底有没有透视,妙计教程(果然真的有挂)-哔哩哔哩w...
透视挂透视!wepoker辅助... 透视挂透视!wepoker辅助器是真的吗,哈糖大菠萝免费辅助器,妙招教程(总是真的有挂)-哔哩哔哩1...
透视教学!pokemmo手机版... 透视教学!pokemmo手机版脚本免费,aapoker万能辅助器,模块教程(本来真的是有挂)-哔哩哔...