Android华为位置更新问题

Android Location update issue Huawei

有没有人在华为 phones(例如 8 Honor,Honor 7)上遇到过位置侦听器的问题。

我有一个实现位置侦听器的后台服务,但对于华为 phones 它在大约 5-6 个位置更新后停止工作。

我已将我的应用程序添加为 phone 管理器中的受保护应用程序。

我不知道这些日志消息是否有助于找出问题所在:

HwLocationPowerTracker - 停止namespace.my.app位置

HwLauncher - Launcher.MotionManager stopMotionAppsReco 服务标志 402 不可用

HwLauncher - Launcher.MotionManager stopMotionAppsReco 服务标志 403 不可用

HwSystemManager - HsmIntentService:last 工作完成!让我们停止服务。

问题的解决方案终于找到了。 在清单文件中

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="My.App.Package"   
<application
android:process="My.App.Package">
</application>

package 和 android:process 必须相等(区分大小写)。

请求唤醒锁时,我也将 "My.App.Tag" 更改为 "LocationManagerService"。

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);           
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "LocationManagerService");

其他必要的设置是将应用程序添加为受保护的应用程序,并保护它不被节电进程捕获。这可以在手机设置中完成。

我对Anders做了同样的事情,不同的是我没有把进程添加到androidManifest。

If you use FusedLocationProviderClient update location, you must add the google play service to the battery optimization whitelist, and turn off the automatic management (the default is on) .
Enable 1.Auto start 2.Allow background , otherwise you will not be able to get location information from google play service

如此病态的OEM,开发商的噩梦——中国移动