从上往下分析
1.notification的使用(app)
/**
* 发送通知
*/
public void setNotification(){
/** start */
//1.得到NotificationManager:
mNotificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
// 创建一个新的Notification对象,并添加图标
notification = new Notification();
// 通知显示的图标
notification.icon = R.drawable.icon_bao;
// 在状态栏(Status Bar)显示的通知文本提示,如:
notification.tickerText = "收到一个新的通知";
//发出提示音,如:
notification.defaults |= Notification.DEFAULT_SOUND;//或
// notification.sound =Uri.parse("file:///sdcard/notification/ringer.mp3");//或
// notification.sound = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI,"6");
//填充Notification的各个属性:
Context context = getApplicationContext();
CharSequence contentTitle = "通知标题";
CharSequence contentText = "通知内容";
//点击通知跳转到哪里
Intent notificationIntent = new Intent(this,CreateMemberActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
//在通知栏上点击此通知后自动清除此通知
notification.flags |= Notification.FLAG_AUTO_CANCEL;
//LED灯闪烁
notification.defaults |= Notification.DEFAULT_LIGHTS;
// 或者可以自己的LED提醒模式:
// notification.ledARGB = 0xff00ff00;
// notification.ledOnMS = 300; //亮的时间
// notification.ledOffMS = 1000; //灭的时间
// notification.flags |= Notification.FLAG_SHOW_LIGHTS;
//手机振动
notification.defaults |= Notification.DEFAULT_VIBRATE;
// 或
// long[] vibrate = {0,100,200,300};
// notification.vibrate = vibrate;
//发送通知
mNotificationManager.notify(1,notification);
/** end */
}
NotificationManager.java(framework)
NotificationManagerService.java(framework)
mNotificationLight是一个Light对象,Light是一个抽象类,LightsService中定义了继承该类的实现类LightImpl
com_android_server_lights_LightsService.cpp(JNI)
HAL层
vendor/mediatek/proprietary/hardware/liblights/lights.c
这里可以控制各种通知对led控制的优先级
其他博客参考http://blog.youkuaiyun.com/u011630458/article/details/22280841