已解决
flutter复制口令返回app监听粘贴板
来自网友在路上 11048104提问 提问时间:2023-10-24 21:54:31阅读次数: 104
最佳答案 问答题库1048位专家为你答疑解惑
void didChangeAppLifecycleState(AppLifecycleState state) {switch (state) {case AppLifecycleState.inactive: // 处于这种状态的应用程序应该假设它们可能在任何时候暂停。break;case AppLifecycleState.resumed: //从后台切换前台,界面可见handle();break;case AppLifecycleState.paused: // 界面不可见,后台break;case AppLifecycleState.detached: // APP结束时调用break;}}
以上代码会在app在初次启动以及app切换回来时触发handle()函数
handle() async {ClipboardData? clipboardData =await Clipboard.getData(Clipboard.kTextPlain); //获取粘贴板中的文本if (clipboardData != null) {if(clipboardData.text!.length>10&&clipboardData.text!.substring(0,9)=='粘贴板口令内容符合'){Future.delayed(const Duration(milliseconds: 200),(){Navigator.of(context).push(CustomRoute(const MyPage()));//跳转页面});}}}
切换App返回时监听粘贴板,如果口令符合要求,做出处理(如跳转页面或者启动弹框)
原文链接:https://blog.csdn.net/weixin_45003123/article/details/127234119
查看全文
99%的人还看了
相似问题
猜你感兴趣
版权申明
本文"flutter复制口令返回app监听粘贴板":http://eshow365.cn/6-23657-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!