`
isiqi
  • 浏览: 16028909 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

控制Android LED灯颜色代码

阅读更多

很多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);

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics