防止用户使用代码关闭 WiFi - Android

发布于 2024-12-26 10:09:01 字数 227 浏览 6 评论 0原文

我正在设计一个使用 wifi 来达到某些目的的应用程序。我想防止用户在我的应用程序运行且设备连接到我的 wifi 网络时从设备的 wifi 设置中关闭 wifi 无线电。有机会做到这一点吗?我在 WifiManager.WifiLock 中读到,他们是这样说的:“请注意,WifiLocks 不能覆盖用户级别的“Wi-Fi 启用”设置,也不能覆盖飞行模式。它们只是在 Wi-Fi 已打开时阻止无线电关闭,但设备空闲。”可以以某种方式完成吗?

I'm designing an app which uses wifi for certain purposes. I want to prevent the user from turning the wifi radio off from the wifi settings of the device while my application is running and the device connected to my wifi network. Is there a chance this can be done? I read in WifiManager.WifiLock and they say this: "Note that WifiLocks cannot override the user-level "Wi-Fi Enabled" setting, nor Airplane Mode. They simply keep the radio from turning off when Wi-Fi is already on but the device is idle." Can it be done somehow??

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

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

发布评论

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

评论(1

蓬勃野心 2025-01-02 10:09:01

您无法阻止用户通过您的代码关闭 wifi。即使你发现了一种邪恶的方法,你也不应该尝试这样做。如果我发现手机中的任何应用程序做了类似的邪恶事情,我将删除该应用程序。 我确信大多数人都和我一样。

如果您出于某种原因确实想这样做,也许您可​​以告诉我们具体情况,我们也许可以帮助您提供您没有想到的不同解决方案

You cannot prevent the user from turning off the wifi from your code. Even if you find out an evil way to do it , you should not try to do it. If I find out any app in my phone does evil things like these, I will just remove the app. I am sure most people are just like me.

If you really want to do it for some reason , perhaps you could tell us what the scenario is and we might be able to help you with a different solution you havent thought about

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文