gpt4 book ai didi

Android - 为服务实现 startForeground?

转载 作者:IT老高 更新时间:2023-10-28 13:01:41 32 4
gpt4 key购买 nike

所以我不确定在哪里/如何实现此方法以使我的服务在前台运行。目前我在另一个 Activity 中通过以下方式开始我的服务:

Intent i = new Intent(context, myService.class); 
context.startService(i);

然后在 myServices 的 onCreate() 中尝试 startForeground()...?

Notification notification = new Notification();
startForeground(1, notification);

所以是的,我有点迷茫,不确定如何实现这一点。

最佳答案

我会先完全填写NotificationHere is a sample project演示 startForeground() 的使用。

关于Android - 为服务实现 startForeground?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6397754/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com