From onCreate() my activity,
I am trying to start the service through the following code:
Intent intent = new Intent(); intent.setClassName(SERVICE_PKG_NAME, SERVICE_NAME); context.startService(intent); //context = MainActivity.this
However, I get the following exception:
java.lang.IllegalStateException: not allowed to start the service Intent (service-name): the application is in the background
Any idea what could be causing this? Stuck on it for hours.
source share