title: How to solve the error: Not allowed to start service Intent : app is in background uid?
body: <p>I have a service which started by on booted completed event it, but the app crashes with the error message as in above. Please help on how can I start my Service on BroadCast receiver event of Boot_Completed.</p>
  
  <p><strong>MyService.kt</strong></p>
  
  <pre><code>class MyService : Service() {
  
      override fun onCreate() {
          Log.d(TAG, "onCreate")
      }
      override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
          return START_STICKY
      }
  
      override fun onBind(intent: Intent?): IBinder? {
          return null
      }
  
      override fun onDestroy() {
          Log.d(TAG, "DO SOME STAFF")
      }
  }
  </code></pre>
  
  <p><strong>MyBroadCaster.kt</strong></p>
  
  <pre><code>class StartRelayServiceAtBootReceiver : BroadcastReceiver() {
       override fun onReceive(context: Context, intent: Intent) {
  
          if (Intent.ACTION_BOOT_COMPLETED == intent.action) {
              val serviceIntent = Intent(context, MyService::class.java)
              context.startService(serviceIntent)
          }
      }
  }
  </code></pre>