`
wang_peng1
  • 浏览: 3904112 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

notification Led灯

 
阅读更多

public class NotificationUtils {
    public static void showStatusbarNotification(Context context, CharSequence text) {
        NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

        Notification notification = new Notification(R.drawable.icon, text, System.currentTimeMillis());
        notification.ledARGB = Color.BLUE;
        notification.ledOnMS = 100;
        notification.ledOffMS = 100; 
        notification.defaults |= Notification.DEFAULT_LIGHTS;
        notification.flags = notification.flags |
            Notification.DEFAULT_LIGHTS | 
            Notification.FLAG_ONLY_ALERT_ONCE | 
            Notification.FLAG_SHOW_LIGHTS;

        CharSequence contentTitle = context.getText(R.string.app_name);
        CharSequence contentText = text;

        Intent notificationIntent = new Intent(context, MyActivity.class);
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

        notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
        nm.notify(0, notification);
    }
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics