BOOT_COMPLETED not received

匿名 (未验证) 提交于 2019-12-03 07:50:05

问题:

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());     }  } }

回答1:

After long researches I find out, that some devices have their own startup manager. And Huawei Mediapad one of those, so:

  1. Go to the settings of device
  2. Find startup manager
  3. Allow app to start.


回答2:

In case your device does not have a startup/boot manager, try checking the app manager. On Lenovo's VibeUI, the app manager has an option "restrict launch",which when enabled prevents the app from receiving BOOT_COMPLETED intent.



转载请标明出处:BOOT_COMPLETED not received
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!