title: Android 11 - java.lang.IllegalStateException Not allowed to start service Intent : app is in background uid UidRecord{}
body: <p>Following crash is reported on Android 11 for Pixel devices.</p>
  <p>Fatal Exception: java.lang.RuntimeException
  Unable to start activity ComponentInfo{}: java.lang.IllegalStateException: Not allowed to start service Intent {}: app is in background uid UidRecord{}</p>
  <p>This is my code where above exception is pointing.</p>
  <pre><code>   val stickyService = Intent(this, StickyService::class.java)
     startService(stickyService)
  </code></pre>
  <p>My StickyService class extends Service class which overrides following methods.</p>
  <pre><code>    public class StickyService extends Service {
  
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
      return START_STICKY;
  }
  
  @Nullable
  @Override
  public IBinder onBind(Intent intent) {
      return null;
  }
  
  @Override
  public void onTaskRemoved(Intent rootIntent) {
      **Update value in preferences here**
  }}
  </code></pre>
  <p>This is happening on Android 11 devices only. Is there major change in Service implementation in Android 11 from Google?</p>