我正在尝试捕获自定义通知按钮上的点击操作。我想避免创建一个扩展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() 方法。(抱歉问题不完整)