Android的 - 服务停止刷卡时,应用程序最近的应用 [英] Android - Service stops when swiping app from recent apps

查看:106
本文介绍了Android的 - 服务停止刷卡时,应用程序最近的应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了与在后台运行的服务的Andr​​oid应用程序
该服务被称为像

I've developed an android application with a service that runs in the background the service is called like that

startService(new Intent(getApplicationContext(),myService.class));

但是当我从最近的应用中移除应用程序,该服务停止,如果我测试它崩溃..
是有办法prevent从最近使用的应用刷卡应用程序时被销毁服务?

but when I remove the app from the recent apps, the service stops and it crashes if I test it.. is there a way to prevent the service from being destroyed when swiping the app from the recent apps?

感谢您

推荐答案

您可以注册服务来使用AlarmManager一个重复循环运行

You can register a service to run on a repeating cycle using AlarmManager

http://developer.android.com/reference/android/app/ AlarmManager.html

如果应用程序没有运行该服务将仍然运行。

The service will run even if the application is not running.

这篇关于Android的 - 服务停止刷卡时,应用程序最近的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆