title: Call react native javascript code when android app is not running
body: <p>I have a widget which starts a intent which invokes react-native javascript code. It does not work when the app is not running as i get 
  java.lang.IllegalStateException: Not allowed to start service Intent app is in background uid UidRecord</p>
  
  <p>I understand that android stoped users being able to do this and recommend the JobScheduler. But i still need a way of calling code across the react-native bridge and not on a timer.</p>
  
  <pre><code>@Override
  public void onEnabled(Context context) {
      super.onEnabled(context);
      // Enter relevant functionality for when the first widget is created
      Intent serviceIntent = new Intent(context, BackgroundTask.class);
  
      context.startService(serviceIntent);
      HeadlessJsTaskService.acquireWakeLockNow(context);
  }
  
  
  public class BackgroundTask extends HeadlessJsTaskService {
      @Override
      protected @Nullable
          HeadlessJsTaskConfig getTaskConfig(Intent intent) {
          Bundle extras = intent.getExtras();
          return new HeadlessJsTaskConfig(
                  "WidgetTask",
                  extras != null ? Arguments.fromBundle(extras) : null,
                  5000,
                  false);
      }
  }
  </code></pre>
  
  <p>I get the following error </p>
  
  <blockquote>
    <p>2019-09-08 20:13:18.874 796-796/com.mypackage E/AndroidRuntime: FATAL
    EXCEPTION: main
        Process: mypackage, PID: 796
        java.lang.RuntimeException: Unable to start receiver mypackage.MyAppWidget: java.lang.IllegalStateException: Not allowed to
    start service Intent { cmp=mypackage/.BackgroundTask }: app is in
    background uid UidRecord{9b991cb u0a160 RCVR idle change:uncached
    procs:1 seq(0,0,0)}</p>
  </blockquote>