I have the following code:
Intent serviceIntent = new Intent(this, ServiceClass.class);
startService(serviceIntent);
I have two classes:
- StartActivity.class
- ServiceClass.class
I start the service from the StartActivity class, but when I start the service by using the “startService()” method the screen changes and I can’t do anything while the service is working on its content inside the “onCreate()” method.
Isn’t the “service” way meant to be used without UI interference compared to the “Activity” way?
In ServiceClass create a new Thread and execute all the code in it. Start your service from activity as you do now, but the code in Service#onStartCommand needs to be in another thread.