Startforeground does not exist

Hello,

I am working with Xamarin in VS Community 2017 and I am trying make a foreground service with a notification, but in the command "Startforeground" the VS says " The name 'StartForeground' does not exist in the context "

How can I could solve this?

Follow the code:

Intent notificationIntent = new Intent(this, typeof(BackgroundService_Android));

PendingIntent pendingIntent = PendingIntent.GetActivity(this, 0,
                notificationIntent, 0);

        Notification notification = new NotificationCompat.Builder(this)                                    
                        .SetContentTitle("My Awesome App")
                        .SetContentText("Doing some work...")
                        .SetContentIntent(pendingIntent).Build();

StartForeground(1337, notification);

Regards.

Answers

Sign In or Register to comment.