对于我正在创建的活动,我希望能够在调用方法时将LED的颜色(指示充电状态的相同LED)更改为Solid RED,并在调用其他方法时将Solid Green更改为Solid Green。到目前为止,我没有尝试过任何工作。也许这在HTC手机上是不可能的。我正在使用HTC Desire 626.我尝试了我的功能,设备插入并没有插入USB。似乎根本没有改变这个通知。我没有看到任何需要包含的特殊权限,我在LogCat中没有例外。
我将提供更改LED的方法,请帮忙!
private void notification_RED(){
AccelerometerResult.setText("The Indicator light should now be Red");
AccelerometerResult.setTextColor(Color.RED);
String ns = getApplicationContext().NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification();
notification.flags = Notification.FLAG_SHOW_LIGHTS;
notification.defaults = 0;
notification.ledARGB = 0xff0000ff;
//notification.ledARGB = Color.RED;
notification.priority = Notification.PRIORITY_MAX;
notification.ledOnMS = 1000;
notification.ledOffMS = 300;
mNotificationManager.notify(1, notification);
}
private void notification_GREEN(){
AccelerometerResult.setText("The Indicator light should now be GREEN");
AccelerometerResult.setTextColor(Color.GREEN);
String ns = getApplicationContext().NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification();
notification.flags = Notification.FLAG_SHOW_LIGHTS;
notification.ledARGB = Color.GREEN;
notification.priority = Notification.PRIORITY_DEFAULT;
notification.ledOnMS = 1000;
notification.ledOffMS = 300;
mNotificationManager.notify(1, notification);
}
答案 0 :(得分:1)
此灯只能在手机锁定时更改。这就是为什么它被称为通知灯。要在屏幕开启时通知某事,请使用Toast,弹出窗口或通知。