startForeground()不显示通知 [英] startForeground() without showing notification

查看:470
本文介绍了startForeground()不显示通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建服务,并使其前景。我试图寻找在谷歌。但是,一些codeS中已包括通知就可以了。但是,在我的应用程序,我不想表现出任何通知。你能给我一些例子吗?或者说,是任何其他方法?我的应用程序服务是做媒体播放器。 如何使系统不杀除应用我的服务杀了它本身(如暂停或按钮停止音乐)。

I want to create service and make it foreground. I try to search at google. But some of codes have included notification on it. But in my app I don't want showing any notification. Can you give me some examples? Or that is any alternative ways? My app service is doing mediaplayer. How to make system not kill my service except the app kill it itself (like pausing or stopping the music by button).

推荐答案

由于Android平台的安全功能,你的不能的,下的任意的情况下,有一个前景化服务,而不还具有通知。这是因为前景化服务消耗资源的重量,并受不同的调度约束(即,它不会因为迅速杀死),比后台服务,用户需要知道什么是可能吃他们的电池。因此,的做到这一点。

As a security feature of the Android platform, you cannot, under any circumstance, have a foregrounded service without also having a notification. This is because a foregrounded service consumes a heavier amount of resources and is subject to different scheduling constraints (i.e., it doesn't get killed as quickly) than background services, and the user needs to know what's possibly eating their battery. So, don't do this.

然而,它的的可能有一个假的通知,也就是说,你可以做一个透明的通知图标(IIRC)。这是非常虚伪的,以你的用户,你没有理由这样做,不是杀死他们的电池,从而创造恶意软件等。

However, it is possible to have a "fake" notification, i.e., you can make a transparent notification icon (iirc). This is extremely disingenuous to your users, and you have no reason to do it, other than killing their battery and thus creating malware.

这篇关于startForeground()不显示通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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