相关疑难解决方法(0)

Android - 为服务实现startForeground?

所以我不确定在何处/如何实现此方法以使我的服务在前台运行.目前我在另一项活动中通过以下方式开始我的服务:

Intent i = new Intent(context, myService.class); 
context.startService(i);
Run Code Online (Sandbox Code Playgroud)

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

Notification notification = new Notification();
startForeground(1, notification);
Run Code Online (Sandbox Code Playgroud)

所以是的,我有点失落,不确定如何实现这一点.

service android android-service

117
推荐指数
7
解决办法
16万
查看次数

标签 统计

android ×1

android-service ×1

service ×1