我正在开发一个相对简单的应用程序,该应用程序在调用意图时会记录一条消息。但是,该应用程序从未收到显式(<package>.ACTION_SILENT_START
或隐式android.intent.action.BOOT_COMPLETED
)的任何意图
AndroidManifest.xml
:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.<snip>.ade.kaiga">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
<application android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/icon"
android:roundIcon="@mipmap/icon_circle"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!-- OnBoot Receiver -->
<receiver
android:name=".BootReceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.MY_PACKAGE_PREPLACED" />
<action android:name="com.<snip>.ade.kaiga.ACTION_SILENT_START" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>
com.<snip>.ade.kaiga.BootReceiver
:
package com.<snip>.ade.kaiga;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class BootReceiver extends BroadcastReceiver {
private static final String TAG = "KaigaBootReceiver";
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "BOOOTTOTOTOTOTOTOTOT");
BootService.enqueueWork(context, new Intent());
}
}
答案 0 :(得分:-1)
您在两个地方都具有RECEIVE_BOOT_COMPLETED权限。您需要在uses-permission元素中使用它。但我认为您不希望在接收者的权限属性中使用它:
dplyr
在此具有该属性,表示您的意图的广播公司必须持有许可。这真的可能会限制接收者的意图。
https://developer.android.com/guide/topics/manifest/receiver-element#prmsn