奥利奥背景服务 [英] Oreo Background Services

查看:112
本文介绍了奥利奥背景服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的应用程序中,我们使用多个服务和意图服务进行BLE通信,麦克风录音等.

Within our application we use multiple Services and Intent Services for BLE communication, microphone recording, etc.

我们已经注意到了新的背景限制和限制(是的,我知道的确很晚了).我已经更改了使用ContextCompat.startForegroundService()函数和将startForeground()与文档中声明的通知一起使用的实现.

We have noticed the newly Background Limitations and Restrictions (Yes, we did notice it rather late, I know). I've changed the implementations for using ContextCompat.startForegroundService() function and using the startForeground() with a notification like it stated in the docs.

但是我们看到,当应用程序被终止时,前台服务也会在几分钟后死亡.应该发生吗?如果应用程序在后台中,前景服务是否应该仅能继续工作?

But we saw that when the application is killed, the Foreground Service dies also after a few minutes. Should it happen? Should the Foreground Service will only continue to work if the app is in the background?

如果是这种情况,电池优化功能会做什么?使服务仅在后台运行?当应用程序作为启用此功能的后台时,是否仍可以终止服务?

Also, if this is the case what does the Battery Optimization feature do? Keeps the Service working while in background only? Can the Service still be killed while the app is the background with this feature on?

我已经阅读了许多有关此文档的文档,但是对于应用程序被杀死时的服务状态,我仍然感到困惑.

I've read a lot of docs regarding it but I'm still confused regarding the state of Service when the application is killed.

我们不介意显示有关这些服务的通知,但我们仍然希望它继续无休止地"工作.

We do not mind showing a notification for those services but we still want it to continue to work "endlessly".

推荐答案

但是我们看到,当应用程序被终止时,前台服务也会在几分钟后死亡.应该发生吗?仅当应用程序在后台运行时,前景服务才应该继续工作吗?

But we saw that when the application is killed, the Foreground Service dies also after a few minutes. Should it happen? Should the Foreground Service will only continue to work if the app is in the background?

是的,它破坏了前台服务..,但是它在几微秒内重新创建了……它的自然行为.即使您通过将其从最近的应用程序中清除掉而杀死了该应用程序..

Yes it destroys foreground service.., But it recreates again within the microseconds... Its natural behaviour. Even if you killed app by swiping it away from recent apps..!!

仅发布您的前台服务代码.没有多余的代码,我将对其进行纠正,以便它可以像我所说的那样工作.

Post your foreground service code only..!! with no extra code and i will correct it so that it can behave the way i stated..

如果是这种情况,电池优化功能会做什么?使服务仅在后台运行?当应用程序作为启用此功能的后台时,是否仍可以终止服务?

Also, if this is the case what does the Battery Optimization feature do? Keeps the Service working while in background only? Can the Service still be killed while the app is the background with this feature on?

如果电池正在优化,那么它可能也不会重新启动前台服务ON_BOOT_COMPLETE

If battery is optimising then it might not re launch your foreground service too ON_BOOT_COMPLETE

我已经阅读了很多关于它的文档,但是对于应用程序被杀死时的服务状态,我仍然感到困惑.

I've read a lot of docs regarding it but I'm still confused regarding the state of Service when the application is killed.

是的,我知道这完全浪费时间,因为Google文档没有直接的文档记录方法,也没有开发人员的示例代码...如果您要为4个以上的android os编写代码,则需要所有代码按照版本代码进行编码.. !!

Yes, i know it is total waste of time as google documentation is having no straight forward ways in documenting and there are no sample codes for developers... If you wants to code for more than 4 android os then all codes needed to coded as per version codes..!!

我们不介意显示有关这些服务的通知,但我们仍然希望它继续无休止地"工作.

We do not mind showing a notification for those services but we still want it to continue to work "endlessly".

这永远不会发生...最终必须使用broadcastreceivers来实现,并且当您希望服务似乎无限运行时..同样,您不能创建静态接收器,也不能像以前一样通过清单调用它们. .您需要在运行时从前台服务创建它.

It never happens... ENDLESSLY must be implemented with the broadcastreceivers as and and when you wants your services can seem to be running endlessly.. Again you can not create static receivers and can not call them via manifest as before... You need to create it from a foreground service in runtime.

在哪里可以获得示例代码? 没有地方... Google没有示例代码...等等等等...

Where i can get example codes? No where... Google has no sample codes... just blah blah blah...

又短暂又甜蜜...我已经失去了整整一年的时间,现在对您的上述问题都已广为人知,并已在应用程序中实施,并且市场上的应用程序运行都比预期的要好...我想帮助他们因为google在文档中缺少它..发布您的代码,让我知道,然后从我这里获取它

Short and sweet... I had lost my complete year and now well known about all above your questions and have implemented it in apps and apps are in market running quite good as expected... And i like to help them all as google lacks it in documentation.. Post your code , Let me know, and Get it worked from me


2

Google已将wrong os(Android)基于wrong conceptwrong implementationwrong supportwrong documentationwrong License进行了开发,这是开放源代码,允许non - standard公司进行修改和使用.现在考虑它的缺点:


Edit : 2

Google has made wrong os ( Android ) based on wrong concept with wrong implementation with wrong support with wrong documentation with wrong License which is open source which allows non - standard companies to modify and use it.. Now Consider its dis-advantages :

  1. 这使开发人员无法编写甚至支持多个版本的应用程序也很麻烦.说LollipopMarshmallow.两种方式都不相同,开发人员已经可以处理1000个案例,然后再进行一次.
  2. 每次开发两个以上版本时,案例变得最糟...完全是一团糟.
  3. 再一次,谷歌会在几个月后不断更改规则...
  4. 没有适当的文档,使开发人员只能选择一种方法..
  5. 这些还不够...,所以再次:-
  1. It frustrates developers to code an app which even supports for more than one version.. Say Lollipop and Marshmallow. Both ways are different and already developer has 1000 cases to handle and then again this..
  2. Case becomes worst to develop when it comes to develop more than 2 versions at a time... Its a complete mess..
  3. Again google keep changing rules over few months of time...
  4. With no proper documentation makes developers only one option open is to pull the hairs out..!!
  5. These all was not sufficient ..., so again :-

Vivo:ColorOs 一加:OxygenOs MI:FunTouchOs . . .

Vivo : ColorOs OnePlus : OxygenOs MI : FunTouchOs . . . .

这是一个庞大的公司列表,这些公司不知道如何修改(以及为什么要修改...?),所以开始修改stock-android ..,其中大多数只允许facebookGoogleWhatsappInstagram,主要的社交应用程序供应商服务仅出现在Boot_complete上.

This is huge list of companies who does not know how to modify ( and why to modify...? ) started modifying stock-android.., most of which only allows facebook, Google, Whatsapp, Instagram, major social app vendors services only to come in memory on Boot_complete.

为什么只有这些服务,为什么不属于我呢??

Why only these services and why not mine..?

因为买家不会购买在上述软件上无法使用的手机.. !!没有人会拿这样的电话.. !!

Because buyers wont buy a phone on which above softwares will not work..!! No one will take such phones..!!

为什么不是我的..

Why not mine..?

这是一家公司

还有其他方法吗??

Is there any other way...?

没办法.. !!当我们在Googles Android Studio上标准开发应用程序时,并且还在装有基本Android系统的Google模拟器上对其进行测试.因此,不保证它是否可以在所有制造商的设备上正常工作.. !!

No way..!! As we develop apps standardly on Googles Android Studio and also tests it on emulators of google which holds stock-android systems..!! So don't guranty will it work on every manufacturers device or not..!!

谁负责所有这些情况?什么是解决方案??

Who is responsible for these all situations.. and what is solution..?

Google对所有这些挫败感负有责任,所有手机制造商已经承担了目前无法处理的程度..Google必须限制修改,还必须实施硬件支持系统.. !!停止这种不受管理的操作系统的最佳方法.

Google is responsible for these all frustrations and all the mobile phone manufactures has taken it the such extent which is now impossible to handle.. Google has to come with restriction on modifications and also hardware support systems must be implemented..!! Best way to dis-continue such unmanaged operating system.

这篇关于奥利奥背景服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆