我创建了一个前台服务。我正在通知抽屉中添加持续通知。 如果我在启动我的服务时打开导航抽屉,它就会开始滞后。
Intent contentIntent = new Intent(this, MainActivity.class);
contentIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(this,0,contentIntent,0);
Intent stopIntent = new Intent(this,Manager.class);
stopIntent.setAction(Types.ACTION_STOP_SERVICE);
PendingIntent stopServiceIntent = PendingIntent.getService(this,0,stopIntent,0);
Notification notification = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.logo)
.setLights(0x008080, 100, 500)
.setTicker(Types.NOTI_TITLE)
.setContentTitle(Types.NOTI_TITLE)
.setContentText(Types.NOTI_CONNECT_TEXT)
.setContentIntent(pendingIntent)
.addAction(0, "Tap here to Stop", stopServiceIntent)
.setPriority(Notification.PRIORITY_MAX)
.setOngoing(true).build();
startForeground(Types.SERVICE_NOTIFICATION_ID,notification);
任何想法,为什么导航抽屉变慢?
答案 0 :(得分:2)
我找到了解决方案,我在Notification中使用的资源很大。把它缩小就解决了这个问题。