android - 前台服务不起作用 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);
}
解决方案
推荐阅读
- python - 如何仅使用我的 df 中的日期而不是所有日期进行绘图
- json - 如果我传递一个将在 Swift/Obj-C 中返回 JSON 的对象,如何创建一个通用类和函数?
- swift - SwiftUI:如何打开字体选择器?
- excel - 计算电力支点的月效率
- uwp - UWP:滚动 ListView 以专注于项目
- angular - 使用 OnPush 在 push/removeAt 后更新 Angular FormArray 内容
- c++ - 如何在 Windows 上为 CLion 添加 OpenGL 和 GLUT?
- css - CSS 清单 2 个单独的列表,每行有 2 个元素,依此类推
- objective-c - 有没有办法在条形图上方和下方添加两个文本值?在 ios danielgindi 图表中
- python-3.x - 带有要作为数据框打开的列表列表的文本文件