
系统震动,响铃,指示灯
发布日期:2021-05-10 02:32:18
浏览次数:22
分类:精选文章
本文共 1516 字,大约阅读时间需要 5 分钟。
ScreenUtils.sound(); ScreenUtils.light(lightDbSet.getT() && ScreenUtils.isForeground(getActivity())) ScreenUtils.shake();
public static void sound() { NotificationManager manager = (NotificationManager) App.getInstance().getCurActivity().getSystemService(NOTIFICATION_SERVICE); Notification notification = new Notification(); notification.defaults = Notification.DEFAULT_SOUND; int soundId = new Random(System.currentTimeMillis()).nextInt(Integer.MAX_VALUE); if (manager == null) { return; } manager.notify(soundId, notification); } public static void light(boolean isNotify) { NotificationManager lightManager = (NotificationManager) App.getInstance().getCurActivity().getSystemService(NOTIFICATION_SERVICE); if (lightManager == null) { return; } if (isNotify) { Notification notification = new Notification(); notification.ledARGB = Color.GREEN;//RED notification.ledOnMS = 100; notification.ledOffMS = 100; notification.flags = Notification.FLAG_SHOW_LIGHTS; lightManager.notify(1, notification); } else { lightManager.cancel(1); } } public static void shake() { Vibrator vibrator = (Vibrator) App.getInstance().getCurActivity().getSystemService(VIBRATOR_SERVICE); if (vibrator != null) { vibrator.vibrate(1000); } }
发表评论
最新留言
留言是一种美德,欢迎回访!
[***.207.175.100]2025年04月20日 16时33分37秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
MVC模型(java)
2021-05-09
[Unity][EXE]封装打包后怎么Debug错误显示output_log.txt
2021-05-09
使用promise封装wx:requset()
2021-05-09
图文追踪PlusToken资产转移行踪(一): BTC部分有1,203个流入交易所
2021-05-09
stm32h743iit6 cubmex 配置QSPI w25128模式问题
2021-05-09
让nginx支持文件上传的几种模式
2021-05-09
快上车!Java技术开发大厂直通车马上启动!
2021-05-09
photon磁力下载工具
2021-05-09
LeetCode 637 二叉树的层平均值-简单
2021-05-09
Java虚拟机结构(内存,类加载器,执行引擎)
2021-05-10
制作横版游戏KillBear第9课:暂停层+屏蔽下层监听
2021-05-10
Redis-day2-五种数据结构类型与数据持久化AOF+RDB
2021-05-10
IOS开发Swif笔记13-初始化
2021-05-10
IOS开发Swift笔记16-错误处理
2021-05-10
【电商吧 - 4】电商场景数值计算那些坑
2021-05-10
Java 天气预报WebService
2021-05-10
Spring中bean的加载过程
2021-05-10
mysql里Date类型的处理
2021-05-10