Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个服务,它在前台运行。我知道如果前台服务被系统杀死,它会在资源可用后重新启动。
我想知道的是,即使前台服务是从“设置”的“运行服务”部分手动终止的,它是否会重新启动?
如果您希望服务在被杀死后重新启动,请在服务对象中使用此方法:
@Override public int onStartCommand(Intent intent, int flags, int startId) { handleCommand(intent); // We want this service to continue running until it is explicitly // stopped, so return sticky. return START_STICKY; }