android Notification 声音和震动正常,呼吸等不亮?求大神

来源:互联网 发布:js原型概念 编辑:程序博客网 时间:2024/04/27 21:42
 NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
        //构建一个通知对象(需要传递的参数有三个,分别是图标,标题和 时间)
        Notification notification = new Notification(R.drawable.ic_launcher,"通知",System.currentTimeMillis());
        Intent intent = new Intent(MyActivity.this,MyActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(MyActivity.this,0,intent,0);
        CharSequence contentText = "iiiiiiiiiii" + a;
        notification.setLatestEventInfo(getApplicationContext(), "通知标题" + a , contentText, pendingIntent);
        notification.flags |= Notification.FLAG_AUTO_CANCEL;//点击后自动消失
        notification.defaults |= Notification.DEFAULT_VIBRATE;
        notification.defaults |= Notification.DEFAULT_SOUND;
        notification.defaults |= Notification.DEFAULT_LIGHTS;
        notification.ledARGB = Color.RED;
        notification.ledOnMS = 1;
        notification.ledOffMS = 0;
        notification.flags |= Notification.FLAG_SHOW_LIGHTS;
        manager.notify(id, notification);//发动通知,id由自己指定,每一个Notification对应的唯一标志
0 0
原创粉丝点击