我正在VS Community 2017中使用Xamarin,并且尝试通过通知创建前台服务,但是VS在命令“ Startforeground”中说“名称'StartForeground'在上下文中不存在”
我该如何解决?
关注代码:
Intent notificationIntent =新的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);
打印
致谢。