Home > Android > Notificationで使用できるLEDの色(HT-03A)

Notificationで使用できるLEDの色(HT-03A)

2月 28th, 2010

 NotificationでLEDを点滅させるときに指定できる色と実際に表示できる色にどれくらい差異が出るか分からなかったので、手元にあるHT-03Aで基本的な色だけ試してみました。

 実際に表示された色はswitch文のそれぞれのcaseにコメント文として書いてあります。

Notification notif = new Notification();
Spinner spinner = (Spinner)findViewById(R.id.spinner);
int index = spinner.getSelectedItemPosition() + 1;
switch (index) {
case 1:
	//赤
	notif.ledARGB = 0xffff0000;
	break;
case 2:
	//緑
	notif.ledARGB = 0xff00ff00;
	break;
case 3:
	//青
	notif.ledARGB = 0xff0000ff;
	break;
case 4:
	//点滅しない
	notif.ledARGB = 0xff000000;
	break;
case 5:
	//本来は黄色のはずだが・・・朱色?
	notif.ledARGB = 0xffffff00;
	break;
case 6:
	//紫
	notif.ledARGB = 0xffff00ff;
	break;
case 7:
	//水色
	notif.ledARGB = 0xff00ffff;
	break;
case 8:
	//白のはずだけど、青紫。
	notif.ledARGB = 0xffffffff;
	break;
case 9:
	//case 1の赤と変わらず。
	notif.ledARGB = 0x99ff0000;
	break;
case 10:
	//case 1の赤と変わらず。
	notif.ledARGB = 0x33ff0000;
	break;
default:
	break;
}
notif.ledOnMS = 300;
notif.ledOffMS = 1000;
notif.flags |= Notification.FLAG_SHOW_LIGHTS;
notif.defaults |= Notification.DEFAULT_LIGHTS;

NotificationManager nm = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);

nm.notify(R.string.app_name, notif);

 結果としては、基本的な色は大丈夫なんですが何故か黄色が駄目で、白色もやっぱり駄目でした。また、ARGBなのでアルファ値も変更してみたんですが、変化が見られません。

 LEDで表現できる色はデバイスによるので、どの端末でも同じ色で表現したいのであれば、なるべく3原色に限定して使用した方がいいのかもしれません。

taga Android ,

  1. No comments yet.
  1. No trackbacks yet.