user940016
user940016

Reputation: 2948

Add a custom event handler to an AppWidget component

Is there any way to add a custom event handler to an AppWidget component, i.e an event handler that's not related to an Intent? I just want a listener function, like components in standard activities have. Thanks.

Upvotes: 0

Views: 187

Answers (2)

user940016
user940016

Reputation: 2948

I actually found a solution to this issue. I can use PendingIntent.getBroadcast and then in the onReceive function of the receiver, I write whatever code I want.

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1007099

Is there any way to add a custom event handler to an AppWidget component, i.e an event handler that's not related to an Intent?

Only if you are the person implementing the home screen that hosts the app widget.

I just want a listener function, like components in standard activities have.

That is only possible from the activity that hosts the app widget, otherwise known as the home screen.

Upvotes: 1

Related Questions