Android,前台服务是否让应用程序保持活动状态?

Android, does foreground service keep app alive?

如果有前台服务运行,Android会杀死public class App extends Application吗?

我不确定它是否重要...如果我从该服务引用 Activity 或 App 中实例化的对象并且 Activity/App 被杀死,将从服务还有效吗?

最后一个问题是...如果与包含静态字段的 class 关联的应用被终止,静态字段会发生什么情况?

Will Android kill public class App extends Application if there is a foreground service running?

类 不是 Android 中的 "killed"。进程终止。创建进程时会创建一个 Application 实例,它会一直存在直到进程终止。

只要前台服务是 运行,它的进程就存在(根据定义),它的 Application 将保持不变。

What happens with static fields if app associated with the class containing the static fields gets killed?

同样,类 不是 Android 中的 "killed"。进程终止。当您的进程终止时,内存中的所有内容都会消失,包括 static 字段及其引用。