RE: App that run in background and display alerts- how to?
created on Feb 4, 2013 9:24:34 AM
You will be able to do this starting a service,which will run at background of your Application,Even you close the application.
A service needs to be declared in the AndroidManifest.xml and the implementing class must extend the Service class or one of its subclasses. The following code shows an example for a service declaration and its implementation.
<service android:name="MyService" android:icon="@drawable/icon" android:label="@string/service_name" > </service> public class MyService extends Service {
@Override public int onStartCommand(Intent intent, int flags, int startId) { //TODO do something useful return Service.START_NOT_STICKY; }
@Override public IBinder onBind(Intent intent) { //TODO for communication return IBinder implementation return null; } } A service runs by default in the same process as the application. in its own thread.
Therefore you need to use asynchronous processing in the service to to perform resource intensive tasks in the background.
|