关闭Kotlin的App-Info电池优化

发布于 2025-02-12 17:21:50 字数 499 浏览 1 评论 0原文

我正在运行一个应用程序,该应用需要在后台使用IMU(加速度计和陀螺仪数据)在后台运行服务,而该应用程序在后台,并且屏幕关闭。一段时间后,随着Android将应用推向后台时,IMU数据停止了。我需要从Kotlin内部禁用它。 截至目前,我发现的唯一方法是将用户重定向到 settings.action_application_details_settings。 但是,从这里设置应用程序电池设置以进行启用,从OEM到OEM都不同,并且从一个版本的Android到另一个版本都不同(屏幕示例

如何在代码中从代码中编辑此设置?

PS: 我已经尝试了电池设置的电源设置和其他应用程序优化,但它不会更改App-Info页面内的设置。

编辑1:由于无法编辑此设置,因此我可以以某种方式在应用程序真正入睡时在我的应用中收到系统消息

I am running an app which needs to run a service in the background using IMU (accelerometer and gyroscope data) in the background, while the app is in background and the screen is off. After sometime, the IMU data stops as Android pushes the app into background. I need to disable this from inside Kotlin.
As of now, the only way I found is to redirect the user to
Settings.ACTION_APPLICATION_DETAILS_SETTINGS.
However, from here setting the app battery settings to Do-not-optimize is different from OEM to OEM and also varies from one version of Android to another (Screen Sample)

How can I edit this setting from within my code?

PS:
I have already tried power settings and other App Optimizations from Battery Settings but it does not change the settings inside the App-Info page.

EDIT 1: Since it is not possible to edit this setting, can I somehow get a System message in my app when the app actually goes to sleep

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

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

发布评论

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

评论(1

美煞众生 2025-02-19 17:21:50

我正在运行一个应用程序,该应用需要在后台使用IMU(加速度计和陀螺仪数据)在后台运行服务,而该应用程序在后台,并且屏幕关闭。

背景中传感器的行为会因设备模型而异,特别是对于较旧的Android版本。有成千上万的Android设备模型。

一段时间后,随着Android将应用推向后台时,IMU数据停止了。我需要从kotlin内部禁用它

对此没有Android SDK方法,对不起。

但是,从这里设置应用程序电池设置以进行毫不限制,从OEM到OEM是不同的,并且从一个版本的Android到另一个版本(屏幕示例)

也有所不同

正确。背景传感器访问也是如此。

I am running an app which needs to run a service in the background using IMU (accelerometer and gyroscope data) in the background, while the app is in background and the screen is off.

The behavior of sensors in the background will vary by device model, particularly for older Android versions. There are tens of thousands of Android device models.

After sometime, the IMU data stops as Android pushes the app into background. I need to disable this from inside Kotlin

There is no Android SDK method for this, sorry.

However, from here setting the app battery settings to Do-not-optimize is different from OEM to OEM and also varies from one version of Android to another (Screen Sample)

Correct. The same thing is true for background sensor access.

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