Startforeground不存在

时间:2018-06-29 13:58:27

标签: java c# android xamarin

我正在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);

打印

enter image description here

致谢。

0 个答案:

没有答案