首页 > 解决方案 > 前台服务不起作用 i LG K10 2017 android 7.0 设备

问题描述

嗨,我有需要启动前台服务的 Android APP,它在华为、索尼和三星设备上运行良好......在 LG K10 2017 android 7.0 设备中,服务无法启动!没有显示通知,请让我知道是否有人有类似的问题或对解决问题有任何想法。谢谢

   public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
    {
        //   if (shared.Readbool("work_in_bg"))
        RegisterForegroundService();
        Thread thread = new Thread(new ThreadStart(request_new_orders));
        thread.Start();
        background_active = true;
        return StartCommandResult.Sticky;
    }

 void RegisterForegroundService()
    {
        ongoing = new Notification(Resource.Drawable.SmartDeliveryAppIcon, "Smart Delivery");
        Intent intent = new Intent(this, typeof(MainActivity));
        intent.SetFlags(ActivityFlags.SingleTop| ActivityFlags.ClearTop);
        pendingIntent = PendingIntent.GetActivity(this, 56, intent, 0);
        ongoing.SetLatestEventInfo(this, "Smart Delivery", "waiting ....", pendingIntent);
        StartForeground((int)NotificationFlags.ForegroundService, ongoing);
    }

标签: androidforeground-service

解决方案


推荐阅读