如何让程序在后台保持挂起状态

  程序的状态分为:前台运行,后台挂起,后台休眠

为了让项目的网络请求保持活跃状态,需要对程序进行设置.

在applicationDidEnterBackground方法中调用下面的方法,可以让程序进入挂起状态,但在未知时间内,可能会被系统设置为休眠,如果在将程序设置为播放器,并且循环播放一个MP3文件,可以保持永久挂起状态.

     UIBackgroundTaskIdentifier task =[application beginBackgroundTaskWithExpirationHandler:^{

         [application endBackgroundTask:task];

    }];

  程序的状态分为:前台运行,后台挂起,后台休眠

为了让项目的网络请求保持活跃状态,需要对程序进行设置.

在applicationDidEnterBackground方法中调用下面的方法,可以让程序进入挂起状态,但在未知时间内,可能会被系统设置为休眠,如果在将程序设置为播放器,并且循环播放一个MP3文件,可以保持永久挂起状态.

     UIBackgroundTaskIdentifier task =[application beginBackgroundTaskWithExpirationHandler:^{

         [application endBackgroundTask:task];

    }];

相关文章:

  • 2021-12-12
  • 2022-01-14
  • 2022-03-02
  • 2022-12-23
  • 2021-06-08
  • 2021-06-20
  • 2021-12-09
  • 2021-04-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
  • 2021-09-16
相关资源
相似解决方案