An application keepalive method, comprising: when a foreground application is switched from a first application to a second application, obtaining a callback probability of the second application relative to the first application, wherein the callback probability of the second application relative to the first application is a probability that the foreground application is switched from the second application back to the first application within first preset duration after the foreground application is switched from the first application to the second application and; when the callback probability of the second application relative to the first application is greater than a preset threshold, increasing a keepalive priority of the first application when the first application is used as a background application, wherein when system resources are insufficient, an electronic device ends a process of at least one background application in ascending order of keepalive priorities, to release system resources; wherein increasing a keepalive priority of the first application when the first application is used as a background application comprises: increasing the keepalive priority of the first application from a default priority to a first priority, wherein after increasing the keepalive priority of the first application from a default priority to a first priority, the method further comprises: when the foreground application is switched from the second application to a transition application, determining whether duration for which the transition application runs in the foreground is greater than second preset duration; and when the duration for which the transition application runs in the foreground is greater than the second preset duration, decreasing the keepalive priority of the first application from the first priority to the default priority. when a foreground application is switched from a first application to a second application, obtaining a callback probability of the second application relative to the first application, wherein the callback probability of the second application relative to the first application is a probability that the foreground application is switched from the second application back to the first application within first preset duration after the foreground application is switched from the first application to the second application and; when the callback probability of the second application relative to the first application is greater than a preset threshold, increasing a keepalive priority of the first application when the first application is used as a background application, wherein when system resources are insufficient, an electronic device ends a process of at least one background application in ascending order of keepalive priorities, to release system resources; wherein increasing a keepalive priority of the first application when the first application is used as a background application comprises: increasing the keepalive priority of the first application from a default priority to a first priority, wherein after increasing the keepalive priority of the first application from a default priority to a first priority, the method further comprises: when the foreground application is switched from the second application to a transition application, determining whether duration for which the transition application runs in the foreground is greater than second preset duration; and when the duration for which the transition application runs in the foreground is greater than the second preset duration, decreasing the keepalive priority of the first application from the first priority to the default priority. when the foreground application is switched from the second application to a transition application, determining whether duration for which the transition application runs in the foreground is greater than second preset duration; and when the duration for which the transition application runs in the foreground is greater than the second preset duration, decreasing the keepalive priority of the first application from the first priority to the default priority.