Java 自定义意图广播

Java 自定义意图广播,java,android,android-8.0-oreo,Java,Android,Android 8.0 Oreo,Android 8.0(Oreo)引入了新的电池使用优化,包括隐式广播。我们有主应用程序和额外安装的插件(APK)。主应用程序发送带有“轮询插件”操作的自定义广播,以确定安装了哪些插件,并与它们共享授权数据。问题是android 8.0上的插件无法接收广播。这是发送广播的th代码: Intent intent=new Intent(); intent.setAction("<PACKAGE_NAME>.POLL_PLUGINS"); intent.putExtra ("auth",

Android 8.0(Oreo)引入了新的电池使用优化,包括隐式广播。我们有主应用程序和额外安装的插件(APK)。主应用程序发送带有“轮询插件”操作的自定义广播,以确定安装了哪些插件,并与它们共享授权数据。问题是android 8.0上的插件无法接收广播。这是发送广播的th代码:

Intent intent=new Intent();
intent.setAction("<PACKAGE_NAME>.POLL_PLUGINS");
intent.putExtra ("auth", "<ENCRYPTED_DATA>"));
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
Intent Intent=新Intent();
intent.setAction(“.POLL_插件”);
intent.putExtra(“auth”和“);
intent.addFlags(intent.FLAG\u包括\u停止的\u包);
发送广播(意图);
和插件的mainfest接收器:

<receiver
        android:name=".PluginReceiver"
        android:enabled="true"
        android:exported="true">
        <intent-filter android:priority="100000000">
            <action android:name="<PACKAGE_NAME>.POLL_PLUGINS"/>
            <action android:name="<PACKAGE_NAME>.plugin1.START"/>
        </intent-filter>
    </receiver>
public class PluginReceiver extends BroadcastReceiver 
{
    @Override
    public void onReceive(Context context, Intent intent)
    {
        Log.d ("Plugin/Receiver","Plugin1 received data"); //<-- not being executed at all
        MainConn.parseBroadCastIntent (context,intent,R.mipmap.ico_crm, MainActivity.class);
    }
}

和插件的接收器:

<receiver
        android:name=".PluginReceiver"
        android:enabled="true"
        android:exported="true">
        <intent-filter android:priority="100000000">
            <action android:name="<PACKAGE_NAME>.POLL_PLUGINS"/>
            <action android:name="<PACKAGE_NAME>.plugin1.START"/>
        </intent-filter>
    </receiver>
public class PluginReceiver extends BroadcastReceiver 
{
    @Override
    public void onReceive(Context context, Intent intent)
    {
        Log.d ("Plugin/Receiver","Plugin1 received data"); //<-- not being executed at all
        MainConn.parseBroadCastIntent (context,intent,R.mipmap.ico_crm, MainActivity.class);
    }
}
public类PluginReceiver扩展了BroadcastReceiver
{
@凌驾
公共void onReceive(上下文、意图)
{

Log.d(“Plugin/Receiver”、“Plugin1接收数据”);//注意:如果您的应用程序目标API级别为26或更高,则不能使用清单声明隐式广播的接收器(不专门针对您的应用程序的广播),但少数不受该限制的隐式广播除外。在大多数情况下,您可以改用计划作业


有关更多详细信息,请参见

谢谢您的回答。我知道这些限制,后来谷歌计划禁止发布目标sdk小于26的应用程序。请您解释如何为两个应用程序(主应用程序和插件)使用计划作业?