Button click event for android widget

后端 未结 5 1127
醉酒成梦
醉酒成梦 2021-01-30 13:16

I have an android widget that fetches data from a server every 10 minutes and display\'s it on the screen.
I\'d like to add a \"Refresh\" button to that widget.
When th

5条回答
  •  一整个雨季
    2021-01-30 13:49

    protected PendingIntent getPendingSelfIntent(Context context, String action) {
        Intent intent = new Intent(context, getClass());
        intent.setAction(action);
        return PendingIntent.getBroadcast(context, 0, intent, 0);
    }
    
    views.setOnClickPendingIntent(R.id.Timm, getPendingSelfIntent(context,
                                  "ham"));
    

    Also prefer URL :

    How to correctly handle click events on Widget

    If you solved it in a different way, please provide this as an answer

提交回复
热议问题