你可以用与localbroadcasts未决的意图? [英] Can you use pending intents with localbroadcasts?
问题描述
我感兴趣的使用意图正在申请与当地广播。
为了使自己清楚,我使用登记接收器和发送广播以下内容: android.support.v4.content.LocalBroadcastManager
我在这工作的服务的本地广播接收机。我想从一个自定义通知的布局,其中包括可点击的物品发送本地广播。
本地广播接收器 - 接收只是简单的动作意图。
我是想这样的事情无济于事:
意图backintent =新意图(GOTO_START_BROADCAST);
的PendingIntent backIntent = PendingIntent.getBroadcast(getApplicationContext(),0,backintent,0);
RemoteViews内容查看=新的RemoteViews(getPackageName(),R.layout.custom_notification);
contentView.setOnClickPendingIntent(R.id.imageView1,backIntent);
我感兴趣的使用意图正在申请与当地广播。
块引用>这是不可能的。
背后的点
的PendingIntent
是允许的其他进程的执行你要求的动作,如发送广播。背后的点
LocalBroadcastManager
是保持播出的您的过程中的因此,一个
的PendingIntent
可以发出一个常规的广播,而是通过LocalBroadcastManager
一个也没有。I am interested in using pending intents with local broadcasts. To make myself clear, I am using the following for registering receivers and sending broadcast:
android.support.v4.content.LocalBroadcastManager
.I have a local broadcast receiver in a service which works. I am trying to send local broadcasts from a custom notification layout which includes click-able items.
The local broadcast receiver - just receives simple action intents. I was trying something like this to no avail:
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);
解决方案I am interested in using pending intents with local broadcasts.
That is not possible.
The point behind a
PendingIntent
is to allow some other process to perform an action you request, such as sending a broadcast.The point behind
LocalBroadcastManager
is to keep broadcast within your process.Hence, a
PendingIntent
can issue a regular broadcast, but not one viaLocalBroadcastManager
.这篇关于你可以用与localbroadcasts未决的意图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!