意图BOOT_COMPLETED在华为设备上不起作用 [英] Intent BOOT_COMPLETED not working on Huawei device
问题描述
我想在我的Android应用中收听APN更改.
I want to listen to APN Changes in my Android App.
因此,我在android.intent.action.BOOT_COMPLETED
上启动了服务.
该服务将启动一个ContentObserver,以监听对
content://telephony/carriers/preferapn
.
Therefore I start a Service on android.intent.action.BOOT_COMPLETED
.
This Service starts a ContentObserver which listens to changes to
content://telephony/carriers/preferapn
.
我在几种不同的设备上测试了此设置(例如,装有Android 5.0的LG Spirit,具有6.0的三星A3,具有7.0的Emulator Nexus5和具有7.0的Huawei P9 Lite)
I tested this setup on a few different devices (e.g. LG Spirit with Android 5.0, Samsung A3 with 6.0, Emulator Nexus5 with 7.0 and Huawei P9 Lite with 7.0)
我的服务的华为电话onCreate
上没有呼叫.
On the Huawei phone onCreate
of my Service is not called.
我将android.intent.action.ANY_DATA_STATE
与在清单中注册的BroadcastReceiver
结合使用的其他方法在这部手机上也无法使用.
My other approach with android.intent.action.ANY_DATA_STATE
in combination with a BroadcastReceiver
which is registerd in the Manifest doesn't work either on this phone.
我的清单的相关部分
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
...
<receiver android:name=".ConnectivityChangeReceiver">
<intent-filter>
<action android:name="android.intent.action.ANY_DATA_STATE" />
</intent-filter>
</receiver>
<receiver android:name=".APNChangedServiceStarter" >
<intent-filter>
<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"/>
</intent-filter>
</receiver>
<service android:name=".APNChangedService"></service>
推荐答案
华为手机具有内置的启动管理器,可能是尚未启用该应用程序.
Huawei Phones have a built-in startup manager, it could be that the app is not yet enabled.
转到设置">全部",然后选择启动管理器". 该程序用于管理Android手机上的启动应用程序. 在华为手机启动后,允许或禁止应用程序自动运行.
Go to Settings > All, and choose Startup manager. This program is used to manage startup apps on Android phone. Allow or disallow app to run automatically after the Huawei phone starts up.
这篇关于意图BOOT_COMPLETED在华为设备上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!