JDS JDS - 1 year ago 237
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);

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 Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download