我有一个以“android.intent.action.BOOT_COMPLETED”动作开始的服务。它启动并正常工作,除非用户已经从开始飞行模式设置,在这种情况下它根本不会被触发。
这是接收器的定义及其实现:我认为没有什么会导致这种行为:
<receiver
android:name="com.applications.-----.-------.NoCoverageAndSpaceFullReceiver"
android:label="StartMyServiceAtBootReceiver"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
为了检查实现是否与错误无关,我检查了如果另一个应该在启动时触发通知的条件确实触发了通知,并考虑到它们定义了通知是否是发射与否是这样的:
boolean a = StaticMethods.isTimeAutomatic(getApplicationContext());
boolean b = StaticMethods.isTimeZoneAutomatic(getApplicationContext());
boolean c = StaticMethods.isMobileAvailable(getApplicationContext(), false);
[...]
if (a && b && c) {
[some more code here]
}
else
{
setMyNotification();
}
而且我正在做的事情是通过显示带有其他错误的消息以及如果在程序的其他任何地方使用飞行模式正确返回 false 如果设备处于飞行模式,它看起来无法在启动时发送通知(在程序的其他地方它可以)。
为了增加怪异,这种情况目前仅在具有 Android API 21 的模拟器中发生,在具有 API 23 的物理设备中它可以正常工作。
关于这怎么可能发生的任何想法?