led分析(app->framework->jni->hal)

本文详细介绍了Android中Notification的使用方法,包括如何通过NotificationManager发送通知、设置通知的各种属性(如图标、标题、内容等),以及如何处理点击通知后的跳转行为。此外,还涉及了通知的高级特性,如LED灯闪烁、声音播放和振动反馈。

从上往下分析

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值