LocalBroadcastManager不接收RemoteViews PendingIntent的广播意图。
那么,如果这是真的,那么RemoteViews和LocalBroadcastManager之间是否有任何想法或方法可以进行通信呢?
我使用RemoteViews作为通知自定义视图,该视图在前台服务中运行。当单击RemoteViews中的按钮时,它将调用服务中的方法。
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
contentView = new RemoteViews(getPackageName(), R.layout.custom);
Intent intent1 = new Intent("myintent");
PendingIntent pi = PendingIntent.getBroadcast(this, 1, intent1, PendingIntent.FLAG_UPDATE_CURRENT);
contentView.setOnClickPendingIntent(R.id.button,pi);但是LocalBroadcastManager没有收到这个。
发布于 2022-01-22 16:59:36
是的,我能解决这个问题。使用另一个BroadcastReceiver作为中间人为PendingIntent接收广播,并通过LocalBroadcastManager发送广播,后者可以通过服务的LBM接收
https://stackoverflow.com/questions/70806235
复制相似问题