Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在上面的Android 8上启动服务_Android - Fatal编程技术网

在上面的Android 8上启动服务

在上面的Android 8上启动服务,android,Android,我有一个应用程序,需要在启动时启动。在AndroidManifast.xml中注册以完成引导,并创建了BroadcastReciver public class BootBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { logI(DEFAULT_TAG

我有一个应用程序,需要在启动时启动。在AndroidManifast.xml中注册以完成引导,并创建了BroadcastReciver

    public class BootBroadcastReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
    
            logI(DEFAULT_TAG, "In onReceive");
    
            if (intent.getAction().equalsIgnoreCase(Intent.ACTION_BOOT_COMPLETED)) {
                logI(DEFAULT_TAG, "++++++++received++++++++++ " + intent.getAction());
               // Start your service here
    
            }
        }
    }
这是我的清单文件

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

    <receiver
        android:name=".BootBroadcastReceiver"
        android:enabled="true"
        android:exported="false">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>

当我运行我的应用程序时,我得到一个错误

BroadcastQueue:不允许后台执行:接收意图

然而,它在版本8以下的Android上工作,但在版本8及以上的Android上不工作

有什么建议吗