BOOT_COMPLETED cannot be retrieved using API 27

The code below does not take action BOOT_COMPLETEDwith API 27, although it works with API 25.

However, this action applies to implicit broadcast exceptions in accordance with official documentation .

When I enter the adb command am broadcast -a android.intent.action.BOOT_COMPLETED, the message below appears on the console:

Background execution not allowed: receiving Intent { act=android.intent.action.BOOT_COMPLETED flg=0x400010 } to com.boottest/.OnBootReceiver

Is there a chance to overcome this problem?

My AndroidManifest.xmlfile:

...
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="27" />

<application ... >
    ....
    <receiver android:name=".OnBootReceiver" android:exported="true" >
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>
</application>
....

My build.gradlefile:

...
android {
    compileSdkVersion 27
    buildToolsVersion "27.0.1"

    defaultConfig {
        applicationId "com.boottest"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    ...
}

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:27.0.+"
    compile "com.facebook.react:react-native:+"  // From node_modules
}

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

My OnBootReceiver.javafile:

package com.boottest;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class OnBootReceiver extends BroadcastReceiver {
  @Override
  public void onReceive(Context context, Intent intent) {
        Log.d("BootTest", " OnBootReceiver - Received a broadcast!");
  }
}
+4
source share
1 answer

The problem was in the Android emulator.

It works as expected, and the class OnBootReceiverevaluates the action BOOT_COMPLETEDat startup when using Genymotion.

+1
source

All Articles