Intent BOOT_COMPLETED not working on Huawei device
Asked Answered
P

2

6

I want to listen to APN Changes in my Android App.

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.

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)

On the Huawei phone onCreate of my Service is not called.

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.

relevant parts of my manifest:

<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>
Pappose answered 11/5, 2017 at 11:20 Comment(8)
did it work on samsung??Fineberg
both approaches worked on all mentioned devices/emulators except the huawei phonePappose
did u turn off fast boot mode on huwaei phone??Fineberg
in huawei devices you have to whitelist your apps on the "telephony manager". You need to whitelist it on autostart and on energy manager. Also, the app has to be opened once before it works. This is absolutely disgusting and you can´t do anything against, only inform your users about in your app. I faced this many times on huawei devices and it takes long time before I find this solution.Celinacelinda
Possible duplicate of BOOT_COMPLETED not working AndroidBarroom
@Celinacelinda i can't even see the option in the telephony manger to enable auto-start for my app and installing the additional app PM Plus from Huawei which should enable this option fails.Pappose
open the telephony manager and swipe from right to left at the bottom menu. Then comes the auto start...Celinacelinda
yeah i can swipe but there is no auto start :(Pappose
I
4

Huawei Phones have a built-in startup manager, it could be that the app is not yet enabled.

from https://www.isunshare.com/android/how-to-control-startup-apps-on-huawei-android.html

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.

Instinctive answered 11/5, 2017 at 11:36 Comment(4)
i don't have that mentioned option in my phonemanager and when i follow the description from youtube.com/watch?v=GIPxTlJOT38 i can't intall the mentioned app PM Plus to enable this settings. Anyway: This might be a solution for us but will never be a reliable solution for end-users.Pappose
there is no solution for the user, only information. This is something Huawei is to blame for, but the user doesn´t understand and maybe blames your app...Celinacelinda
On Huawei Mate 10 pro, running Pie do: Settings -> Battery -> App launch -> Disable automatic management for your appSpic
@Arkady, this is the most relevant answer to date, please post it as an answer.Hogtie
S
10

Just for an update, Huawei changed the menu path in the Android 9 version.

On Huawei Mate 10 pro the way to get to this menu:
Settings -> Battery -> App launch -> Disable automatic management for your app.

A pop-up will appear, asking what you want to allow (all true by default). make sure that the first, Auto-launch is enabled

Spic answered 1/2, 2020 at 17:34 Comment(0)
I
4

Huawei Phones have a built-in startup manager, it could be that the app is not yet enabled.

from https://www.isunshare.com/android/how-to-control-startup-apps-on-huawei-android.html

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.

Instinctive answered 11/5, 2017 at 11:36 Comment(4)
i don't have that mentioned option in my phonemanager and when i follow the description from youtube.com/watch?v=GIPxTlJOT38 i can't intall the mentioned app PM Plus to enable this settings. Anyway: This might be a solution for us but will never be a reliable solution for end-users.Pappose
there is no solution for the user, only information. This is something Huawei is to blame for, but the user doesn´t understand and maybe blames your app...Celinacelinda
On Huawei Mate 10 pro, running Pie do: Settings -> Battery -> App launch -> Disable automatic management for your appSpic
@Arkady, this is the most relevant answer to date, please post it as an answer.Hogtie

© 2022 - 2024 — McMap. All rights reserved.