I'm trying to catch a click action on a button of a custom notification. I want to avoid creating a class extending BroadcastReciever
. To do this I am coding as follows inside my service class:
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);
But it doesn't work. Am I loosing something?
Edit: With "It doesn't work" I mean OnReceive() method is never called when I click on button. (Sorry for the incomplete question)