我有兴趣在本地广播中使用挂起的 Intent 。
为了清楚起见,我使用以下内容来注册接收器和发送广播:android.support.v4.content.LocalBroadcastManager
。
我在服务中有一个本地广播接收器可以正常工作。我正在尝试从包含可点击项目的自定义通知布局发送本地广播。
本地广播接收器 - 只接收简单的 Action Intent 。 我正在尝试这样的事情无济于事:
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.
那是不可能的。
PendingIntent
背后的要点是允许一些其他进程 执行您请求的操作,例如发送广播。
LocalBroadcastManager
背后的要点是在您的进程中保持广播。
因此,PendingIntent
可以发出常规广播,但不能通过 LocalBroadcastManager
发出。
关于android - 你能在本地广播中使用待处理的 Intent 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15790734/