【发布时间】:2016-07-26 19:44:02
【问题描述】:
我正在尝试捕捉自定义通知按钮上的点击操作。我想避免创建一个扩展BroadcastReciever 的类。为此,我在我的服务类中编码如下:
this.registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.v ("Myreceiver", "on click catch")
}
}, new IntentFilter("MyRemoteViewsBroadcast"));
PendingIntent pi = PendingIntent.getBroadcast(this, 0, new Intent("MyRemoteViewsBroadcast"), 0);
remoteviews.setOnClickPendingIntent(R.I'd. Button, pi);
但它不起作用。我失去了什么吗?
编辑:“它不起作用”是指当我单击按钮时永远不会调用 OnReceive() 方法。 (抱歉问题不完整)
【问题讨论】:
-
“不起作用”是什么意思,您遇到的具体问题是什么?
-
感谢您的快速答复!我的意思是点击时不会调用 onReceive() 方法,所以不会出现 Log...
标签: android notifications broadcastreceiver custom-notification