1
2
3
4
5
6
7
|
notification.ledARGB = Color.RED; notification.ledOffMS = 0 ; notification.ledOnMS = 1 ; notification.flags = notification.flags | Notification.FLAG_SHOW_LIGHTS; |
控制顏色和閃爍頻率是為向使用者傳遞資訊的另一種途徑。
在地震監視的例子中,使用設備的LED來輔助傳達級別,説明使用者從顏色上來感受地震的級別。在下麵的片段中,LED的顏色取決於地震的級別,而閃爍的頻率相反地關聯于地震的影響:
java代碼:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
int color; if (quake.getMagnitude() < 5.4 ) color = Color.GREEN; else if (quake.getMagnitude() < 6 ) color = Color.YELLOW; else color = Color.RED; newEarthquakeNotification.ledARGB = color; newEarthquakeNotification.ledOffMS = ( int )vibrateLength; newEarthquakeNotification.ledOnMS = ( int )vibrateLength; newEarthquakeNotification.flags = newEarthquakeNotification.flags |Notification.FLAG_SHOW_LIGHTS; |
全站熱搜
留言列表