该文件说 intentservice 隐式调用 stopself 。所以想知道是否可以将 intentservice 设置为 Sticky。
谢谢
该文件说 intentservice 隐式调用 stopself 。所以想知道是否可以将 intentservice 设置为 Sticky。
谢谢
粘性就像您可以赋予服务的属性(它不是属性),它在系统因内存不足而关闭后被激活,当系统有足够的内存时,它将重新启动返回 START_STICKY 的服务在他们的 onStartCommand 上,否则将保持关闭。在 IntentServices 中,您不能返回 START_STICKY (至少我还没有找到方法),但您可以做的是:
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
return START_REDELIVER_INTENT;
}
目前我在我的应用程序中使用它并且效果很好