title: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord Application crashed in Android 10.0 OS
body: <p>1.I have started a forground service from mainActivity. Also added permission in manifest file android.permission.FOREGROUND_SERVICE but application is crashing.</p>
  
  <p>2.Application is working bellow 9.0 but crashing in android 10.</p>
  
  <pre><code>    public class SocketService extends Service {   
               @Override   
              public void onCreate() {   
                  super.onCreate();       
  
              mCommunicationThread = new Thread(new SocketThread());      
              mCommunicationThread.start();   
  
            if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.O) {   
                          String channel = createNotificationChannel(getString(R.string.app_name), "Service");   
                          Notification notification = new NotificationCompat.Builder(this, channel)    
                                  .setContentTitle("Name")//.build();      
                                  .setContentText("Do not close it").build();   
                          startForeground(10012, notification);               
                      }  
          }  
        /**
           * Thread class which runs in background to accept data which is received
          from server via socket
           */      
  
            private class SocketThread implements Runnable {          
                  @Override    
                  public void run() {     
  
                       }       
                  }         
  
  
          /**
             Create notification channel
           */
               private String createNotificationChannel(String channelId, String channelName) {    
                      NotificationChannel chan = new NotificationChannel(channelId,    
                              channelName, NotificationManager.IMPORTANCE_HIGH);    
                      chan.setLightColor(Color.BLUE);    
                      chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);       
                      NotificationManager manager = (NotificationManager)        
                getSystemService(Context.NOTIFICATION_SERVICE);     
                      manager.createNotificationChannel(chan);    
                      return channelId;    
                  } 
  
  
          }       
            /**
             Start service from MainActivity
           */
  
             Intent intentService = new Intent(MainActivity.this,SocketService.class);    
            this.startForegroundService(intentService);    
  </code></pre>