Android onStartCommand Service

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 {
public void onCreate() {

public IBinder onBind(Intent intent) {
    return null;

public int onStartCommand(Intent intent, int flags, int startId) {
    Intent DI = new Intent(getBaseContext(), AUTOSERVICES.class);
    return START_STICKY;

public boolean onUnbind(Intent intent) {
    return super.onUnbind(intent);



I think you should reconsider some work done because your service is taking too much resources and that shouldnt be happening any way. There are many applications with a lot of services but non have problem of restarting the device for that matter.

However if you want to restart a service you have to stop and then start the service again.

stopService(new Intent(this, YourService.class));
startService(new Intent(this, YourService.class));

Hope it helps.

Need Your Help

JDBC ERROR: operator does not exist: date = integer

java sql postgresql jdbc

String checkAvailable_flight = String.format("SELECT Flightid, flightdate,"

StreamReader weird error with �

c# streamreader

StreamReader reads '–' (alt+ 0150) as � even if I have UTF-8 encoding and I have detectEncodingFromByteOrderMarks (BOM) set to true. Can any one guide me on this ?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.