未收到BOOT_COMPLETED [英] BOOT_COMPLETED not received
问题描述
我创建了一个Android应用程序,该应用程序应在BOOT之后启动服务.它可以在Nexus 5手机上正常工作,但无法在华为平板电脑(Mediapad X2)上运行.我正在使用Android 5.0/API21.
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>
我在SO中搜索类似的问题( BOOT_COMPLETED无法运行的Android ),并添加了QUICKBOOT_POWERON的意图以及WAKE_LOCK权限,但没有任何改变.
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());
}
}
}
推荐答案
经过长期研究,我发现某些设备具有自己的启动管理器.而华为Mediapad就是其中之一,所以:
After long researches I find out, that some devices have their own startup manager. And Huawei Mediapad one of those, so:
- 转到设备的设置
- 查找启动经理
- 允许应用启动.
这篇关于未收到BOOT_COMPLETED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!