显示闪烁的LED的前景活动/屏幕上 [英] Showing flashing LED for foreground activity / screen on

查看:140
本文介绍了显示闪烁的LED的前景活动/屏幕上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图把LED闪动对我在前台活动,但它的工作原理,只有当屏幕处于关闭状态。

是否有可能将LED开启主动活动与屏幕上的?

我的code:

 保护无效导致(){
  注意notif =新的通知();
  notif.ledARGB = 0xFF0000ff;
  notif.flags = Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_ONGOING_EVENT;
  notif.ledOnMS = 800;
  notif.ledOffMS = 200;
  notificationManager.notify(LED_NOTIFICATION_ID,notif);
}
 

解决方案

目前第一款Android LED指示灯是非常依赖于硬件。二 - 有管理LED代替通知类没有API的 FLAG_SHOW_LIGHTS 标志和一些标志管理闪光持续时间和LED您所使用的颜色。 通知是一个消息可以显示给用户的应用程序的正常的UI LED指示灯的首要目的之外是present其他通知信息给用户,当屏幕是关闭的。因此,答案是肯定的NO。该LED才会开始闪动,如果你的屏幕是关闭的,当你重新打开它,它会停下来。而且也没有办法打开和关闭指示灯,当你想,并把它当任何的应用程序活动是在前台,因为它是由操作系统内部管理。

I'm trying to turn the LED-flashing on for my activity in foreground, but it works only when the screen is off.

Is it possible to turn the LED on for active activity with the screen on?

My code:

protected void led() {
  Notification notif = new Notification();
  notif.ledARGB = 0xFF0000ff;
  notif.flags = Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_ONGOING_EVENT;
  notif.ledOnMS = 800; 
  notif.ledOffMS = 200; 
  notificationManager.notify( LED_NOTIFICATION_ID, notif );
}

解决方案

At first Android LED indicator is very hardware dependent. Second - there is no API for managing LED instead of Notification class with its FLAG_SHOW_LIGHTS flag and several flags for managing flash duration and LED color which you use. Notification is a message you can display to the user outside of your application's normal UI the primary purpose of LED indicator is to present additional notification information for the user when the screen is off. So the answer is definite NO. The LED will only start flashing if your screen is off and it’ll stop when you turn it back on. And there is no way to turn on and off LED when you want and to turn it when any of the application activities is in foreground, because it is managed by the OS internally.

这篇关于显示闪烁的LED的前景活动/屏幕上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆