21

我有兴趣在本地广播中使用未决意图。为了清楚起见,我使用以下内容注册接收器和发送广播:android.support.v4.content.LocalBroadcastManager.

我在一个有效的服务中有一个本地广播接收器。我正在尝试从包含可点击项目的自定义通知布局发送本地广播。

本地广播接收器 - 只接收简单的动作意图。我正在尝试这样的事情无济于事:

Intent backintent = new Intent("GOTO_START_BROADCAST");
PendingIntent backIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, backintent, 0);
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification);
contentView.setOnClickPendingIntent(R.id.imageView1, backIntent);
4

1 回答 1

28

我有兴趣在本地广播中使用未决意图。

这是不可能的。

a 背后的要点PendingIntent是允许其他一些进程执行您请求的操作,例如发送广播。

背后的要点是在您的流程LocalBroadcastManager中保持广播。

因此, aPendingIntent可以发出常规广播,但不能通过LocalBroadcastManager.

于 2013-04-03T15:34:50.287 回答