简体   繁体   中英

Kill an App with background Services

I have an application where also running 5 background services. Base service class contains method:

public override void OnTaskRemoved(Intent rootIntent)
{
    base.OnTaskRemoved(rootIntent);
    StopSelf();
}

Above code is working when application is being closed by user - servcies are being stopped. However I have implemeted another feature - user can close an application from itself. To achive that I have found this part of code to use:

Process.KillProcess(Process.MyPid());

Application is being closed while debugging but after application is released there is magic sign

" Application has stopped ".

After some reading I figured out it has to be something with services. Did somone faced similar issue ?

您可以使用Finish()方法进行活动,并调用StopService()方法来停止特定服务

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM