• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Need Help in Background Process

Hi Friends,
I am new to develop android applications. i want to develop the background application to my android mobile like if i press back button application has to hide and again if i press application icon again then it has to do the running application like
ex : in my application a timer is running for 100seconds
after 10 seconds i pressed backbutton (applicaiton has to minimize or hide) and if i press application again (after 40 sec) it has to run continuously.
Please help me here.
Thanks.
 
If you're wanting to create a "background process" then I'd suggest creating a Service. There are some advantages to these: 1) they were designed to be long running (as your GUI maybe transient), 2) they allow for a GUI (or other system) to "plug in" and "unplug" as needed - allowing the service to handle functionality that should not be directly implemented within your GUI (think communications or database logic for example), 3) when Android needs resources and begins to shut down automatically other applications it tends to allow Services to remain up and running, and 4) Android will automatically start your service - if it's not already up and running. To be a good neighbor, though, your Service should shut itself down if it has no other pending requests.

Services do not have GUI's and should be used to build capabilities that your other applications can share and will need ... that's why I use examples like communications and data persistence .... most apps require these and there's no point in rebuilding these for every app you plan to build, in my opinion.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones