Looks like force stop should prevent app from running and it\'s even disable all app\'s alarms. However I found that notification in Google Calendar still shown fine even after
If you start a service in Application Class than your service will be always running even though if a user terminates or force stop from task manager, it will run again.
To create service specifically in Android studio Right click on app from Project Explorer and then New > Service > Service
Create a service:
public class ServiceName extends Service {
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// do your jobs here
return super.onStartCommand(intent, flags, startId);
}
}
Now create an Application Class and start Service in Application Class
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
startService(new Intent(this, ServiceName.class));
}
}