【发布时间】:2015-02-21 03:45:40
【问题描述】:
我的应用具有绑定到活动的远程、前台辅助服务。当我清除最近的任务(通过滑动)服务销毁。我怎样才能防止杀死服务。
<service android:enabled="true"
android:exported="false"
android:stopWithTask="false"
android:process=":xplay"
android:name="com.perm.x.Services.PlayingService"/>
这是我的绑定方式(在 onResume 中)
Intent serviceIntent = new Intent(this,PlayingService.class);
startService(serviceIntent);
bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE);
这是我解除服务绑定的方法(在 onPause 中)
unbindService(serviceConnection);
【问题讨论】:
-
您的设备是什么版本的Android?服务最终会被系统重启吗?
-
4.1 果冻豆。是的,服务在大约 4 秒后重新启动并发出通知
-
我也测试其他应用程序。除了 Poweramp 播放器外,几乎所有人都有相同的行为。他只是无视杀戮
-
@Karakuri 有什么建议吗?
-
如果几秒后重启,真的有问题吗?