I have a service that I am trying to run constantly as long as the user has it on. The problem is the service uses a ton of memory; I'm guessing because it notifies the users and displays images constantly. So I put the bulk of my code in another activity. The service just calls the activity.
The issue is that I'm trying to use the return Start_Sticky to restart the service when it needs to. It takes about 2 hours before it uses up enough memory to need to restart. When it does restart it doesn't do the onStartCommand am I missing something?
public class AUTOAlarmService extends Service {
@Override
public void onCreate() {
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Intent DI = new Intent(getBaseContext(), AUTOSERVICES.class);
DI.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(DI);
return START_STICKY;
}
@Override
public boolean onUnbind(Intent intent) {
return super.onUnbind(intent);
}
}