Broadcast class not recieving broadcast intent for BOOT_COMPLETE

Viewed 73

I needed to restore alarm after reboot for this I added this broadcast receiver:

public class ClsRestartAlarm extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {

    if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {

        Logging.logMessage("Broadcast");
        Intent i = new Intent(context, BootService.class);
        context.startService(i);
    }
}
}

and registered in manifest like this:

  <receiver android:name=".classes.ClsRestartAlarm"
        android:enabled="true">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

and as result of broadcast I'm doing this:

public class BootService extends IntentService {

public BootService() {
    super("boot service");
}

@Override
protected void onHandleIntent(Intent intent) {
    AlarmManagerUtils.setStartAlarm();
    AlarmManagerUtils.setEndAlarm();
}
}

I guess I'm not receiving BOOT_COMPLETE broadcast in ClsRestartAlarm class, because after restart alarm was not set and I was unable to get notification(the starting alarm start a job scheduler for sending notification and end alarm cancels job scheduler)also I have BOOT_COMPLETE permission like this:

<uses-permission android:name="ANDROID.PERMISSION.RECEIVE_BOOT_COMPLETED"/>
1 Answers
Related