Service的stopForeground用于从前台状态中删除此服务,代码如下:
//frameworks/base/core/java/android/app/Service.java
public abstract class Service extends ContextWrapper implements ComponentCallbacks2,
ContentCaptureManager.ContentCaptureClient {
private IActivityManager mActivityManager = null;
public final void stopForeground(@StopForegroundSelector int notificationBehavior) {
try {
mActivityManager.setServiceForeground(
new ComponentName(this, mClassName), mToken, 0, null,
notificationBehavior, 0);
} catch (RemoteException ex) {
}
}
}
ActivityManagerService setServiceForeground
调用IActivityManager的setServiceForeground方法,IActivityManager是一个接口,ActivityManagerService实现了这个接口。
待补充