2

INTRODUCTION

I want to keep my app always on top of application stack ,so that on low memory condition the app never gets removed from memory. The app generally fetches location and keep in database and runs mostly on background. the work is mainly done in services (foreground service). and for this purpose the service has to run continuously without any interruption.

MY THEORY

The solution i am thinking of is that on some time interval i start an activity and close it . and take the app to the background. in this way the app will always be on top of stack. but in this condition the whole app will come to foreground and i want to again take it to background. but this will (probably) keep it on top of stack.

TRIED TILL NOW

  • I have tried notification service and failed , on low memory conditions the notification service is also removed .
  • tried updating the notification service's message at regular interval but no good.
  • started the service on START_STICKY & START_REDELIVER_INTENT but still no good result.

RESEARCH

i have seen this , this , this and this SO links but got no good result.

I dont want my activity to be removed from the stack and the service to run as long as it want without any interruption from low memory condition.

Update

i tried using the moveTaskToBack() . i just started a service and at every interval it start an activity then finish it and call the moveTaskToBack() . but when the device is locked it bring the previous app in the stack to front and goes one step back in stack. i don,t want that .but in normal device unlocked condition its working fine.

Do anyone have any suggestion.

Community
  • 1
  • 1
Sagar Nayak
  • 2,138
  • 2
  • 19
  • 52

0 Answers0