I have created an Android application that should start a service after BOOT. It works just fine on a Nexus 5 phone, but I can not make it work on a Huawei tablet (Mediapad X2). I am using Android 5.0 / API 21.
The manifest has the proper permissions/intents according to the guidelines.
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<receiver
android:name=".BootBroadcast"
android:enabled="true"
android:exported="true"
android:label="BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
</intent-filter>
</receiver>
I search SO for similar issues (BOOT_COMPLETED not working Android) and have added the QUICKBOOT_POWERON intent, as well as the WAKE_LOCK permission but nothing has changed.
The Broadcast Receiver is just starting the service
public class BootBroadcast extends BroadcastReceiver {
private static final String TAG = "GrandUnion-Boot";
@Override
public void onReceive(Context context, Intent intent) {
Log.e(TAG, "Boot_Completed RECEIVED");
try{
context.startService(new Intent(context,MyService.class));
Log.i(TAG, "Boot Completed - start service");
}catch(Exception e){
Log.e(TAG,e.toString());
}
}
}
After long researches I find out, that some devices have their own startup manager. And Huawei Mediapad one of those, so:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With