Java NotificationCompat.Builder setLights();不起作用
我仔细准备了我列出的链接,但它不起作用,我没有足够的声誉发表评论,所以我不得不再次添加相同的问题。链接像Java NotificationCompat.Builder setLights();不起作用,java,android,android-notifications,Java,Android,Android Notifications,我仔细准备了我列出的链接,但它不起作用,我没有足够的声誉发表评论,所以我不得不再次添加相同的问题。链接像 我的代码是这样的: final NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); //点击通知执行下面的事件 Intent intent = new Intent(mContext,TestActivity.class); PendingIn
我的代码是这样的:
final NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
//点击通知执行下面的事件
Intent intent = new Intent(mContext,TestActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
final Notification noti = new NotificationCompat.Builder(mContext)
.setContentTitle("你有一封新的邮件")
.setContentText("鉴于你最近优秀表现,给你一个小红星")
.setSmallIcon(R.drawable.wechat_fav)
.setContentIntent(pendingIntent)
.setVibrate(new long[]{0,500})
.setPriority(Notification.PRIORITY_HIGH)
.setAutoCancel(true)
.setDefaults(Notification.FLAG_SHOW_LIGHTS)
.setLights(0xffffffff, 300, 300 )
.setWhen(System.currentTimeMillis())
.build();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
manager.notify(1,noti);
}
},4000);
如您所见,我将处理程序设置为延迟通知,以使其工作,我甚至关闭了屏幕,但仍然无法工作,但标题和内容会显示出来,手机会震动 此外,我还设置了权限:
<uses-permission android:name="android.permission.FLASHLIGHT"/>
根据您的问题,不需要上述许可。在Galaxy note 5的android 7上也有同样的问题