gpt4 book ai didi

android - android : battery being drained in background 中的 react-native 应用程序

转载 作者:行者123 更新时间:2023-11-29 01:03:26 24 4
gpt4 key购买 nike

我有一个用 React-Native 构建的应用程序,它在后台运行时会耗尽 Android 设备上的大量电池电量。需要显着减少应用程序的电池使用量。

该应用使用 react-native-background-geolocation (mauron85) 跟踪位置,但仅每 20 分钟(10 快速间隔)获取一次位置更新。

电池使用报告屏幕(大部分时间在后台):

enter image description here

可能是一些依赖或错误的版本?

我的 package.json:

{
"name": "AwesomeApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"base-64": "^0.1.0",
"d3-interpolate": "^1.1.5",
"es6-promise": "^4.1.1",
"firebase": "^4.6.0",
"lodash": "^4.17.4",
"lodash.range": "^3.2.0",
"moment": "^2.19.2",
"numeral": "^2.0.6",
"react": "16.0.0-alpha.12",
"react-native": "^0.48.2",
"react-native-android-location-services-dialog-box": "^2.3.2",
"react-native-checkbox": "^2.0.0",
"react-native-drawer": "^2.5.0",
"react-native-fbsdk": "^0.6.3",
"react-native-fcm": "^10.0.3",
"react-native-firebase": "^3.2.0",
"react-native-google-places": "^2.4.2",
"react-native-google-signin": "^0.12.0",
"react-native-keyboard-aware-scroll-view": "^0.4.1",
"react-native-mauron85-background-geolocation": "^0.5.0-alpha.1",
"react-native-navbar": "^2.0.1",
"react-native-permissions": "^1.0.1",
"react-native-popup-dialog": "^0.9.38",
"react-native-push-notification": "^3.0.1",
"react-native-router-flux": "^4.0.0-beta.25",
"react-native-spinkit": "^1.1.1",
"react-native-splash-screen": "^3.0.1",
"react-native-svg": "^5.4.1",
"react-native-tab-view": "0.0.70",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-persist": "^5.2.2",
"redux-thunk": "^2.2.0"
},
"devDependencies": {
"babel-eslint": "^8.0.2",
"babel-jest": "21.2.0",
"babel-preset-react-native": "4.0.0",
"eslint-config-rallycoding": "^3.2.0",
"jest": "21.2.1",
"react-test-renderer": "16.0.0-alpha.12"
},
"jest": {
"preset": "react-native"
},
"rnpm": {
"assets": [
"./assets/fonts/"
]
}
}

背景地理定位的配置:

BackgroundGeolocation.configure({
desiredAccuracy: 10,
stationaryRadius: 50,
distanceFilter: 50,
startForeground: false,
debug: false,
startOnBoot: true,
stopOnTerminate: false,
locationProvider: BackgroundGeolocation.ACTIVITY_PROVIDER,
interval: 1200000, //default 1200000 = 20 minutes
fastestInterval: 600000, //DEFAULT 600000 = 10 MINUTES
activitiesInterval: 1200000, //default 1200000 = 20 minutes
stopOnStillActivity: false
});

我感谢任何帮助的尝试:)

最佳答案

这是我的 2 美分。屏幕截图显示 Stay Awake : 7h 26m。这似乎是问题所在。似乎您在某处获取未释放的部分唤醒锁。检查Stuck Partial Wake Locks解决方案。它说,我引用:

A partial wake lock becomes stuck if it is held for a long time while your app is running in the background (no part of your app is visible to the user). This condition drains the device's battery because it prevents the device from entering lower power states.

关于android - android : battery being drained in background 中的 react-native 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49284486/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com