Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Run App in Background

Greetings,

I'm trying to allow my user to close the app but still maintain a connection which listens for events. An icon should appear in the status bar and when the user clicks on the notification, they are taken back to the app.

Any ideas on how I might go about this?

Many thanks in advance,

like image 869
Eamorr Avatar asked Dec 23 '10 20:12

Eamorr


2 Answers

I think you want to implement a service. http://developer.android.com/reference/android/app/Service.html

like image 41
Kalendae Avatar answered Oct 30 '22 09:10

Kalendae


Use a Service, a Notification, and startForeground(). Here is a sample application from one of my books demonstrating this technique.

like image 157
CommonsWare Avatar answered Oct 30 '22 09:10

CommonsWare