Please help with very simple android widget button click. Getting very frustrated. :(

后端 未结 2 1656
野趣味
野趣味 2021-01-13 14:21

I have poured over every example that I can find and I have gone through the official documentation from google. All I am trying to do is create a toast notification from a

2条回答
  •  误落风尘
    2021-01-13 14:34

    As bigstones wrote, you need to use broadcast. Sample code:

    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"));
    

提交回复
热议问题