【发布时间】:2018-07-17 21:02:49
【问题描述】:
Android 8.0 (Oreo) 引入了新的电池使用优化,包括隐式广播。我们有主应用程序和额外安装的插件 (apks)。主应用程序发送带有动作“POLL_PLUGINS”的自定义广播,以确定已安装哪些并与它们共享授权数据。问题是在 android 8.0 上的插件中无法接收广播。这是发送广播的代码:
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);
以及插件的主要接收者:
<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);
}
}
在以前的机器人上运行良好。如何使用相同的方案或有其他解决方法?
【问题讨论】:
标签: java android android-8.0-oreo