private void startForeground() {
String channelId ="com.thundersoft.bugreport";
String channelName ="BugReport";
NotificationChannel notificationChannel =null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationChannel =new NotificationChannel(channelId,
channelName, NotificationManager.IMPORTANCE_DEFAULT);
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
manager.createNotificationChannel(notificationChannel);
startForeground(1, new Notification.Builder(this, channelId).build());
}
}
网友评论