系统震动,响铃,指示灯
发布日期: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);        }    }

 

上一篇:retrofit --post请求
下一篇:RecycleView滚动条添加

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2025年04月20日 16时33分37秒