попробуйте это, он будет поддерживать службу в фоновом режиме.
BackServices.class
public class BackServices extends Service{
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// Let it continue running until it is stopped.
Toast.makeText(this, "Service Started", Toast.LENGTH_LONG).show();
return START_STICKY;
}
@Override
public void onDestroy() {
super.onDestroy();
Toast.makeText(this, "Service Destroyed", Toast.LENGTH_LONG).show();
}
}
в вашей MainActivity onCreate
удаляет эту строку кода
startService(new Intent(getBaseContext(), BackServices.class));
Теперь служба будет работать в фоновом режиме.