I am using an empty activity to start a sticky service. I start the service using the following code.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent service = new Intent(this, MyService.class);
service.setAction("com.company.test.MyService");
startService(service);
finish();
setContentView(R.layout.activity_transparent);
}
The problem is that if the activity gets killed it will cause the service to restart. Is there a way to avoid this problem?
Note: I am killing the application by swiping it out of the task manager, and not the activity's finish() call.