控制Android LED灯颜色的代码实例
时间:2022-12-30 02:53:20
很多Android手机上都配有LED灯,比如HTC的手机在充电、新来短信等时候都会有响应的指示,其实很简单的这都是NotificationManager的一些参数而已,下面Android123给大家说下如何通过代码控制LED灯的闪烁,因为有些机型没有LED灯或颜色种类较少,发布时需要真机观察。
final int ID_LED=19871103;
NotificationManager nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification();
notification.ledARGB = 0xFFFFFF; //这里是颜色,我们可以尝试改变,理论上0xFF0000是红色,0x00FF00是绿色
notification.ledOnMS = 100;
notification.ledOffMS = 100;
notification.flags = Notification.FLAG_SHOW_LIGHTS;
nm.notify(ID_LED, notification);
nm.cancel(ID_LED);
标签:LED灯,颜色
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java解析调用webservice服务的返回XML串详解
2023-11-07 02:42:01
Java面试题解析之判断以及防止SQL注入
2023-05-26 18:08:59
利用栈使用简易计算器(Java实现)
2023-07-22 02:02:11
![](https://img.aspxhome.com/file/2023/2/61402_0s.jpg)
Android使用selector修改TextView中字体颜色和背景色的方法
2021-06-19 17:28:18
mybatis如何实现saveOrUpdate
2021-07-18 10:33:11
java9迁移注意问题总结
2022-07-19 11:26:30
java 实现线程同步的方式有哪些
2023-01-13 01:26:14
IDEA 2020.1 搜索不到Chinese (Simplified) Language Pack EAP,无法安装的问题
2023-11-10 23:54:01
![](https://img.aspxhome.com/file/2023/6/59316_0s.jpg)
JVM类加载机制原理及用法解析
2021-08-17 00:22:29
![](https://img.aspxhome.com/file/2023/3/68173_0s.jpg)
C#通过属性名称获取(读取)属性值的方法
2023-10-10 11:49:06
springboot如何读取自定义配置项
2021-06-18 10:44:53
javaweb 项目初始配置的方法步骤
2021-12-23 17:34:23
![](https://img.aspxhome.com/file/2023/8/63418_0s.jpg)
Flutter 如何封装文本输入框组件
2023-09-27 02:54:51
github上的java项目怎么运行(面向小白)
2022-12-23 23:29:09
![](https://img.aspxhome.com/file/2023/8/94348_0s.png)
java实现在原有日期时间上加几个月或几天
2023-08-06 16:39:48
mybatis-plus 扩展批量新增的实现
2023-07-14 14:24:13
关于springboot 中使用httpclient或RestTemplate做MultipartFile文件跨服务传输的问题
2023-01-04 15:38:04
![](https://img.aspxhome.com/file/2023/0/110790_0s.jpg)
C#根据年月日计算星期几的函数
2022-03-17 04:50:50
GraalVM和Spring Native尝鲜一步步让Springboot启动飞起来66ms完成启动
2023-07-19 10:34:35
![](https://img.aspxhome.com/file/2023/0/122330_0s.jpg)
C++ lambda函数详解
2023-06-20 07:49:43