JDS JDS - 5 months ago 110
Android Question

Android - implementing startForeground for a service?

So I'm not sure where/how to implement this method to make my service run in the foreground. Currently I start my service by the following in another activity:

Intent i = new Intent(context, myService.class);
context.startService(i);


And then in myServices' onCreate() I try the startForeground()...?

Notification notification = new Notification();
startForeground(1, notification);


So yeah I'm a bit lost and unsure of how to implement this.

Answer

I'd start by completely filling in the Notification. Here is a sample project demonstrating the use of startForeground().

Comments