Android关于Notification的问题

使用NotificationManager创建通知时

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(1, localBuilder.build());

可以成功创建,但是过了几秒后就报错

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: gd.gz.ds.example, PID: 23628
    android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{52e0b76 u0 gd.gz.ds.example/.service.MyService}
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1737)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

如果用startForeground(1,notification);就不会报错,但是通知没办法取消(有设置setAutoCancel),而我要可以取消的所以用的是NotificationManager但是会报错。
求大神指导!!!!!!