如何保证android始终开机?

发布于 2024-10-17 13:51:43 字数 396 浏览 8 评论 0原文

我有一个项目要求,要求 android 始终开机并在后台运行服务。 虽然我可以从 2.2 开始使用 START_STICKY 来处理服务部分,但我仍然无法保证设备始终处于开启状态。 或者至少,如果连接到电源,则在关闭时应该自动启动。

在现实世界中有什么解决方案吗?除了制作新固件之外,我还需要一些想法或解决方法。 谢谢。

更新:我认为更好更清楚。就我而言,我没有使用 Android 作为手机,因此不会有用户。它的使用就像一个运行android的硬件设备,一旦与我的应用程序一起安装,就没有人可以访问它。并且始终连接电源和互联网。用户还可以访问其电源控制。

我同意这不能从应用程序内部或使用 Android API 来完成。但这是一个现实世界的问题,我迫切需要一个解决方案。任何事情,即使与编程无关,也可能是机械的或其他什么。

I have a project requirement which requires android to be always powered on with service running in background.
While I can handle service part, as from 2.2 by using START_STICKY, still there is no way I can guarantee the device always is on.
Or at-least if connected to power-supply should boot automatically, if switched off.

Is there any solution for this in real world ? Except for going to make a new firmware, I need some ideas or a workaround.
Thanks.

UPDATE: I thought to be better more clear. In my case I am not using android as a mobile and there will be no user. Its use is like an hardware equipment running android which once installed with my app, no one has access to it. And is always connected to power supply and internet. Also user will have access to its power-supply controls.

I agree it cannot be done from inside application or using Android APIs. But this is a real world problem, and I desperately need a solution on this. Any thing even not related to programming, may be mechanical or anything.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

烛影斜 2024-10-24 13:51:44

我发现了一个应用程序,可让您在设备关闭并充电时启动设备,

该应用程序名为 NoMoarPowah!

它可以在特定设备上运行,并且需要 root。如果电池已充电或已充电 15%,或者有足够的电量可以启动,您就可以启动设备。

尝试一下...

I found an app that allows you to boot your device when it is off and charging

The app called NoMoarPowah!

It can run on specific devices and requires rooting. You can boot your device if the battery charged or 15% charged or has enough juice to boot.

Try it...

平定天下 2024-10-24 13:51:43

我也想做同样的事情,但在网上找不到任何解决方案。然后我想出了一个硬件解决方案,我在我的博客中对此进行了描述 http:// /iembed.tumblr.com/post/9055351385/boot-on-power

希望这有帮助!

I also wanted to do the same but could not find any solution online. Then I came up with a hardware solution which I have described in my blog here http://iembed.tumblr.com/post/9055351385/boot-on-power

Hope this helps!

落叶缤纷 2024-10-24 13:51:43

我怀疑你的问题是否有解决方案。关闭充电事件永远不会到达顶层,而是在低硬件级别处理(打开屏幕并显示充电状态)。因此您的应用程序将永远没有机会对此类事件做出反应。
第二件事是,用户始终拥有有关硬件的权力。如果他决定关闭该设备,它应该而且很可能会关闭。当然,他最后的机会就是取出电池。

所以你的解决方案就是拒绝这个要求,因为它无法完成。

I doubt that there is a solution for your problem. The event of charging when turned off will never reach the top level but will be handled on low hardware level (turn on screen and display the charging status). So your application will never have a chance to react to such an event.
The second thing is, that the user has always the power about the hardware. If he decide to turn off the device, it should and probably will turn off. The last chance he has is to remove the battery, off course.

So your solution is to reject this requirement because it can't be done.

凉世弥音 2024-10-24 13:51:43

我不知道你想做什么,但这看起来是一个非常糟糕的主意......任何人都会立即卸载这样的应用程序。如果我关闭手机,我不希望有一个应用程序在没有询问我的情况下打开我的手机。

无论如何,这看起来不可能做到...... android API 不允许你这样做。

I don't know what you want to do but this looks like a really bad idea... Anyone would immediately uninstall an app like this. If I turn off my phone I don't want to have an app which turns my phone on without asking me.

Anyway this looks impossible to do... The android API does not allow you to do it.

蓝海 2024-10-24 13:51:43
 PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
            mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK
                    | PowerManager.ACQUIRE_CAUSES_WAKEUP,
                   "Any String");
mWakeLock.acquire();
 PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
            mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK
                    | PowerManager.ACQUIRE_CAUSES_WAKEUP,
                   "Any String");
mWakeLock.acquire();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文