Android 后台服务和闹钟 [英] Android background services and alarms

查看:64
本文介绍了Android 后台服务和闹钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近遇到了一个问题,当设备进入睡眠模式时 Android 4.4 杀死了我的应用程序的 ServiceAlarmManager (START_STICKY 参数没有帮助).我尝试了很多东西,但没有任何效果是我需要的.

Recently encountered with a problem when Android 4.4 killed my app's Service and AlarmManager when device going into a sleep mode (START_STICKY param doesn't helps). I tried a lot of things, but nothing works as I need.

在我的任务管理器应用程序中,我总是看到很多非默认应用程序的进程,例如 Google+、Skype、Google Drive 结束了其他一些实时工作且从未被系统杀死的进程.

In my task manager app I always see a lot of processes of non-default apps such as Google+, Skype, Google Drive end some else that working in real time and never were killed by the system.

我想问有经验的开发者如何创建ServiceAlarm不会被系统杀死或者这在某些Android上是不可能的代码>程序集?

I want to ask more experienced developers how to create Service or Alarm that will not be killed by the system or this is impossible on some Android assemblies?

推荐答案

这不是一种编程答案,因为不工作的原因不在你的代码里面.两周前我也遇到了这个问题.我的服务总是停止,我一直不明白为什么,直到我在设置中检测到省电"选项(我的设备华为 Ascend Mate 7)导航:

This is not a kind of programming answer, because the reason of not working is not inside Your code. I stumpled about that too before two weeks. My service allways stopped and I never understood why, until I detected the "Power Saving" Option inside the settings (my device Huawei Ascend Mate 7) Navigate:

设置 --> 省电 --> 在顶部的电源信息 --> 屏幕关闭后继续运行.

Settings --> Power Saving --> on the top Power Info --> keep running after screen off.

在这里您可以启用或禁用应用程序,如果屏幕进入睡眠状态,这些应用程序应在后台运行.

Here You can enable or disable apps, that should run in the background if the screen goes to sleep.

另外,如果这不是正确答案,评论太长了,也许它可以帮助其他人解决这个问题.

Also if it is not the correct answer, It´s too long for a comment, and maybe it helps others with this problem.

这篇关于Android 后台服务和闹钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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