我有一个应用程序,即使重新启动设备后,该应用程序仍在后台连续运行服务 为此,我在下面的接收器中使用了
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
直到Android Oreo都运行良好 但是在Android Pie中,只有在解锁手机后,服务才能开始。
重启手机后要启动服务,需要解锁。
重新启动后不解锁手机即可启动服务的解决方案
答案 0 :(得分:0)
我相信您正在寻找
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED"/>
,并在清单中添加到您的接收者:
android:directBootAware="true"
此操作由设备发送,然后用户在重新启动时解锁手机。检出: