小米和Oppo中限制了后台服务

问题描述 投票:2回答:1

我们正在开发一个在前台服务中运行MQTT的应用程序。问题出在小米Redmi Note 7上,该服务在我们终止该应用程序后被终止,但在其他品牌上运行正常。我没有在Oppo和Vivo上测试该应用程序,但是当我搜索它们时也遇到了问题。在服务的onCreate方法中,我调用了startForeground(NOTIFICATION_ID, notification),清单中的服务声明如下:

<service
    android:name=".service.mqtt.MqttService"
    android:enabled="true"
    android:exported="false"
    android:foregroundServiceType="location" />

我也将foregroundServiceType更改为connectedDevice|dataSync|mediaPlayback并添加了android:stopWithTask="false"并以START_STICKY的服务方法返回了onStartCommand,但仍无法正常工作。

我们正在开发一个在前台服务中运行MQTT的应用程序。问题出在小米Redmi Note 7上,该服务在我们终止该应用程序后被终止,但在其他品牌上运行正常。我没有...

android mqtt foreground-service xiaomi
1个回答
0
投票

最后我找到了答案here

© www.soinside.com 2019 - 2024. All rights reserved.